<template>
  <div class="c-bg-sgray c-pb20" v-if="topData&&homeWorkInfo">
    <audio id="audio" @ended="playAudioEnd" class="c-pf c-p-l-100"></audio>
    <div class="teaHeadbg c-pt40 c-p c-flex-column c-alignc-sb">
      <div class="c-ph24">
        <div class="c-flex-row c-justify-sb c-aligni-center" @click="clickGoClockDetail">
          <div class="c-fs32 c-fw600 c-fc-white c-ww540 c-text-ellipsis1">{{topData.name}}</div>
          <span class="iconfont c-fs24 c-fc-sgray">&#xe635;</span>
        </div>
        <div class="c-fs22 c-fc-white c-opacity70 c-mt14" v-if="workType == 1">
          打卡周期：{{topData.startTime2}} 至 {{topData.endTime2}} {{ topData.startHour2 }}-{{ topData.endHour2 }}
        </div>
      </div>
      <div class="c-flex-row c-justify-sb c-aligni-center c-pl24 c-mt14">
        <div class="c-flex-row c-justify-center c-aligni-center">
          <div class="c-flex-row c-mr20" v-if="topData.studentList.length > 0">
            <div class="c-ww36 c-hh36 c-brp50 c-text-hidden c-bg-white"
              v-for="(item, index) in topData.studentList" :key="index" v-if="index < 3" :class="index != 0?'c-ml-4':''">
              <img class="c-bd1-white c-ww36 c-hh36 c-brp50 c-text-hidden" :src="$addXossFilter(item.headimgurl,require('@/assets/defult_head.png'))" alt="" />
            </div>
            <div class="c-ww36 c-hh36 c-brp50 c-text-hidden c-bg-white c-ml-4">
              <img class="c-bd1-white c-ww36 c-hh36 c-brp50 c-text-hidden" :src="$addXossFilter(require('@/assets/i/wap/clockIn/iconHead.png'))" alt="" />
            </div>
          </div>
          <div class="c-fs22 c-fc-white c-flex-row c-justify-center c-aligni-center">{{topData.studentNum}} 人参与打卡 ｜ {{topData.submitNum}} 次打卡</div>
        </div>
        <div class="c-flex-row c-justify-center c-aligni-center c-translucent-balck30 c-pl16 c-pv10 c-pr12 c-br-tl24 c-br-bl24" @click="clickInviteFriend">
          <div class="iconfont c-fs28 c-fc-white">&#xe632;</div>
          <div class="c-fs20 c-fc-white c-ml4">邀请好友</div>
        </div>
      </div>
      <div class="c-flex-row c-aligni-center c-justify-sa c-hh100 c-w100 c-translucent-balck30 c-mt36">
        <div v-if="workType == 1" class="c-flex-column c-justify-center c-aligni-center c-w20" @click="clickGoCalendar">
          <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe626;</div>
          <div class="c-fs20 c-fc-white">日历</div>
        </div>
        <div class="c-flex-column c-justify-center c-aligni-center c-w20" @click="clickGoRank">
          <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe734;</div>
          <div class="c-fs20 c-fc-white">排行榜</div>
        </div>
        <div @click="clickShowSign" class="c-flex-column c-justify-center c-aligni-center c-w20">
          <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe736;</div>
          <div class="c-fs20 c-fc-white">日签</div>
        </div>
        <div @click="clickGoStudyHistory('')" class="c-flex-column c-justify-center c-aligni-center c-w20">
          <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe624;</div>
          <div class="c-fs20 c-fc-white">学习记录</div>
        </div>
        <div class="c-flex-column c-justify-center c-aligni-center c-w20" v-if="homeWorkInfo.isTeacher==1||homeWorkInfo.isTeacher==2" @click="clickGoTottal">
          <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe732;</div>
          <div class="c-fs20 c-fc-white">打卡统计</div>
        </div>
        <div class="c-p c-flex-column c-justify-center c-aligni-center c-w20" v-if="
          (workType == 2 || workType == 1) &&
            homeWorkInfo.enableRemind != 0">
          <div @click="clickSubscribeNotices" class="c-flex-column c-justify-center c-aligni-center">
            <div class="iconfont c-fs36 c-fc-white c-mb8">&#xe652;</div>
            <div class="c-fs20 c-fc-white">{{
              subscribeStatus == 1 ? "取消通知" : "开启通知"
            }}</div>
          </div>
          <div class="c-pa c-p-r0 c-p-t68 c-pz99" v-if="subscribeStatus != 1 && noticesToast">
            <div class="top_triangle c-pa"></div>
            <div class="c-bg-white c-pv12 c-ph20 c-br10 c-box-shadow4">
              <div class="c-ww340 c-fs20 c-fc-gray c-flex-row c-justify-sb">
                <span>开启打卡通知，打卡动态一键掌握</span>
                <!-- <div class="c-ph20 c-fs18 c-lh32">|</div> -->
                <div @click.stop="
                  () => {
                    noticesToast = false;
                  }
                " class="iconfont c-fs18 c-lh32">
                  &#xe84e;
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="c-bg-white c-flex-row c-aligni-center c-pl24 c-pv14 c-bgTittle c-p" v-if="enableBanner">
      <div class="iconfont c-fs20 c-fc-FF2F0B c-mr8">&#xe6ad;</div>
      <div class="c-fs20 c-fc-FF2F0B">简化操作，提高学习效率！就使用创匠打卡小程序参与打卡！</div>
      <div class="iconfont c-fs20 c-fc-FF2F0B">&#xe635;</div>
      <div class="open-tag-wrap" v-if="isSupport">
        <wx-open-launch-weapp
          class="launch-btn"
          :appid="`${appid}`"
          :username="username"
          :path="`${path}?${wxappQuery}`"
          @error="handleErrorFn"
          @launch="handleLaunch"
        >
          <script type="text/wxtag-template">
            <!-- 这里是为了撑开元素，让其可以被点击，不添加template会报错，添加了template不添加内容也会报错 -->
            <div style="padding: 10000px">
            </div>
          </script>
        </wx-open-launch-weapp>
      </div>
      <div v-else class="open-tag-wrap" @click="clickGoWxApp"></div>
    </div>
    <div class="c-flex-row c-fs28 c-aligni-center c-ph24 c-pv20 c-justify-sb" v-if="(tabIndex==0&&workType!=2)||(tabIndex==0&&workType==2&&unFinishedHwList.length!=0)">
      <div class="c-fc-xblack c-fw600">
        {{workType == 1?'当日主题':workType == 2?'未完成作业':'课时内容'}}
      </div>
      <div v-if="workType == 2" class="c-fs22 c-fc-sblack" @click="tabtag(1)">查看全部作业 ({{topData.homeworkNum}})</div>
    </div>
    <div class="c-mb10 c-ph24" v-if="(tabIndex==0&&workType!=2)||(tabIndex==0&&workType==2&&unFinishedHwList.length!=0)">
      <div class="c-flex-column c-br20 c-pt32 c-text-hidden" :class="workType==2?'theme-bg-gradient18002':'c-bg-white'">
        <!-- 日历打卡头部 -->
        <div v-if="workType == 1">
          <div class="c-mb30 c-flex-row c-aligni-center c-justify-center c-p">
            <div class="c-fs28 c-fw-b">{{curSelectYearMonth}}</div>
            <div @click="clickGoCalendar" class="iconfont c-fs36 c-fc-sblack c-pa c-p-r32 c-p-t0">&#xe626;</div>
          </div>
          <div class="c-flex-row c-flex-center">
            <div @click="clickChangeDate(index)" v-for="(item, index) in myCalendarList" :key="index"
              class="c-flex-column c-flex-center c-flex-1 c-textAlign-c c-flex-grow1 c-w0 c-br12 c-pv10 c-p">
              <div class="c-fs20 c-fc-gray c-pb30">{{ item.week }}</div>
              <div class="c-fs24 c-brp50 c-ww44 c-hh44 c-lh44 c-textAlign-c" :class="[{'theme-bd1 theme-bg-10 theme-fc':item.day=='今'},{'theme-fc theme-bg-10':(item.type == 2 || item.type == 3)},{'data-active theme-bd1 theme-bg': item.date == curSelectDate}]">
                <span :class="item.type == 0 ? 'c-fc-gray' : ''">{{item.day}}</span>
                <!-- 打卡且选中 -->
                <!-- <div class="icon-sign" v-if="(item.type == 2 || item.type == 3)">
                  <div class="sign-color" :class="{'sign-active': item.date == curSelectDate}"></div>
                </div> -->
              </div>
            </div>
          </div>
        </div>
        <!-- 作业打卡头部 -->
        <div v-else-if="workType == 2" class="c-ph24 c-fs20 c-aligni-center c-pt8">
          <div v-for="(item, index) in unFinishedHwList" :key="index" @click="clickGoClockIn(item,'',1)" v-if="index < 3">
            <div class="c-mb20 c-pv30 c-ph18 c-bg-white c-br20 c-p c-text-hidden c-flex-row c-justify-sb c-aligni-center c-p">
              <div v-if="enableCenter">
                <div class="open-tag-wrap" v-if="isSupport">
                  <wx-open-launch-weapp
                    class="launch-btn"
                    :appid="`${appid}`"
                    :username="username"
                    :path="`${path}?${wxappQuery}`"
                    @error="handleErrorFn"
                    @launch="handleLaunch"
                  >
                    <script type="text/wxtag-template">
                      <!-- 这里是为了撑开元素，让其可以被点击，不添加template会报错，添加了template不添加内容也会报错 -->
                      <div style="padding: 10000px">
                      </div>
                    </script>
                  </wx-open-launch-weapp>
                </div>
                <div v-else class="open-tag-wrap" @click="clickGoWxApp"></div>
              </div>
              <div>
                <div class="c-flex-row c-justify-sb c-aligni-center">
                  <div class="c-fs28 c-fc-xblack c-text-ellipsis1 c-ww380">{{item.name}}</div>
                </div>
                <div class="c-mt18 c-fs20 c-fc-gray c-flex-row c-justify-sb c-aligni-center">
                  <div>{{item.startTime}}至{{item.endTime}}</div>
                </div>
              </div>
              <!-- <div class="c-flex-row c-flex-center c-pl20">
                <span class="iconfont c-fs28 c-fc-sgray">&#xe908;</span>
              </div> -->
              <div class="c-pv8 c-ph16 c-fs24 c-fc-white c-br32 theme-bg">打卡</div>
            </div>
          </div>
        </div>
        <!-- 闯关打卡头部 -->
        <div v-else-if="workType == 3" class="c-bg-white c-ph24">
          <div class="c-flex-row c-fs20 c-aligni-center c-justify-sb">
            <div class="c-fc-xblack c-fs24">已完成{{hasBreak}}/{{levelNum.length}}课时</div>
            <div class="c-fc-gray c-fs24">{{finishPeopleNum}}人已全部学完</div>
          </div>
          <div ref="levescroll"
            class="c-w100 c-contexty-hidden c-contextX-scroll c-ws-n c-mt30">
            <div class="c-inlineblack c-fs24 c-brp50 c-ww44 c-hh44 c-lh44 c-textAlign-c c-mr40 c-p"
              v-for="(item, index) in levelNum" :key="index"
              ref="levelIndex"
              :class="[{'theme-bd1': item.hwId == curHwId},{'theme-bg-10 theme-fc':item.isUnlock==1||item.reorder-1==hasBreak},{'nounlock c-fc-xblack':item.isUnlock==0&&item.reorder-1!=hasBreak}]"
              @click="chooseLockNum(item,index)">
              <span>{{topData.isExperienceLesson>=item.reorder?'试':item.reorder}}</span>
              <div class="iconfont c-fs20 c-fc-gray c-pa c-p-r0 c-p-b-03" v-if="item.isUnlock==0&&item.reorder-1!=hasBreak">&#xe84d;</div>
            </div>
          </div>
          <!-- <span @click="clickGoPre" v-show="homeWorkInfo.beforeId">上一关</span> -->
          <!-- <div class="c-flex-grow1 c-w0 c-fs30 c-textAlign-c">
            <span @click="clickGoLevelList">{{ homeWorkInfo.name }}</span>
            <span v-if="homeWorkInfo.hasPermission" @click="clickGoLevelList" class="iconfont c-fs24">&#xe6a9;</span>
          </div> -->
          <!-- <span @click="clickGoNext" v-show="homeWorkInfo.nextId">下一关</span> -->
        </div>
        <!-- 主题与打卡按钮 -->
        <div class="c-mt10">
          <div class="c-pt30 c-fs28 c-fw-b c-ph24 c-pb20" v-if="
            workType == 3 &&
              homeWorkInfo.description &&
              homeWorkInfo.description.length > 0 &&
              (homeWorkInfo.cover != '' ||
                (homeWorkInfo.description.length == 1
                  ? homeWorkInfo.description[0].content != ''
                  : true))
          ">
            主题
          </div>
          <!-- 课程介绍 -->
          <div v-if="enablePreview==0&&((workType == 1 && homeWorkInfo.isExpire == 2)||(workType == 3 && homeWorkInfo.isUnlock == 0))
          " class="c-fc-gray c-fs24 c-pt20 c-textAlign-c c-mb40">
            <img class="c-ww240 c-center c-mb24" :src="require('@/assets/i/wap/clockIn/no_theme.png')" alt="">
            任务未开始，不支持查看任务
          </div>
          <div v-else>
            <div v-if="homeWorkInfo.cover&&workType!=2" class="c-text-hidden c-ph24 c-pv10">
              <img class="c-w100 c-br12" :class="cfg.isCopyPicture == 0 ? 'imgCloseBig' : ''" :src="$addXossFilter(homeWorkInfo.cover)" alt="" />
            </div>
            <!-- 课程介绍 -->
            <clock-course-detail-com v-if="workType!=2&&homeWorkInfo.description &&homeWorkInfo.description.length > 0 &&(homeWorkInfo.description.length == 1? homeWorkInfo.description[0].content != '': true)"
              :isShowTheme='isShowTheme'  :status="homeWorkInfo.status" :description="homeWorkInfo.description" @clickShowVideo="clickShowVideo"></clock-course-detail-com>
            <div v-if="
              workType == 1 && !homeWorkInfo.hwId
            " class="c-fc-gray c-fs24 c-pt20 c-textAlign-c c-mb40">
              <img class="c-ww240 c-center c-mb24" :src="require('@/assets/i/wap/clockIn/no_theme.png')" alt="">
              老师暂未添加主题要求
            </div>
          </div>
          <div class="c-pb20">
            <!-- 作业打卡，未过期，状态为未打卡或打到一半 -->
            <div v-if="
              workType == 2 && unFinishedHwList.length>3
            " @click="isShowhw = true" class="c-fs24 c-flex-row c-flex-center theme-fc c-mlr-auto">
              查看更多 <span class="iconfont c-fs22 theme-fc">&#xe635;</span>
            </div>
            <!-- 日历打卡，未过期，状态为未打卡或打到一半休息日无需打卡 -->
            <div v-else-if="workType == 1 &&homeWorkInfo.isRestDay==1&&homeWorkInfo.isExpire == 1 &&
              (homeWorkInfo.status == 0 || homeWorkInfo.status == 2)" class="c-mt20 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center c-bg-ccc c-fc-white c-fs26 c-mlr-auto">
              今日休息
            </div>
            <!-- 强制阅读 -->
            <div v-else-if="
                   isShowTheme==1&&readTime!=0&&
                     workType == 1 &&
                     homeWorkInfo.isExpire == 1 &&
                     ((homeWorkInfo.status == 0 || homeWorkInfo.status == 2)||(homeWorkInfo.status==1&&(maxSignCount==-1||(maxSignCount>homeWorkInfo.hasSignCount))))"
              class="c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center theme-bg c-fc-white c-fs26 c-mlr-auto">阅读中({{readTime}}s)</div>
            <!-- 日历打卡，未过期，状态为未打卡或打到一半 -->
            <div v-else-if="
              workType == 1 &&((isShowTheme==1&&readTime==0)||isShowTheme==0)&&
                homeWorkInfo.isExpire == 1 &&
                ((homeWorkInfo.status == 0 || homeWorkInfo.status == 2)||(homeWorkInfo.status==1&&(maxSignCount==-1||(maxSignCount>homeWorkInfo.hasSignCount))))
            " @click="clickGoClockIn" class="c-p c-mt20 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center theme-bg c-fc-white c-fs26 c-mlr-auto">
              {{homeWorkInfo.buttonText}}
              <div v-if="enableCenter">
                <div class="open-tag-wrap" v-if="isSupport">
                  <wx-open-launch-weapp
                    class="launch-btn"
                    :appid="`${appid}`"
                    :username="username"
                    :path="`${path}?${wxappQuery}`"
                    @error="handleErrorFn"
                    @launch="handleLaunch"
                  >
                    <script type="text/wxtag-template">
                      <!-- 这里是为了撑开元素，让其可以被点击，不添加template会报错，添加了template不添加内容也会报错 -->
                      <div style="padding: 10000px">
                      </div>
                    </script>
                  </wx-open-launch-weapp>
                </div>
                <div v-else class="open-tag-wrap" @click="clickGoWxApp"></div>
              </div>
            </div>
            <!-- 日历打卡，已过期，有补打卡，状态为未打卡或打到一半 -->
            <div v-else-if="
              workType == 1 &&
                homeWorkInfo.isExpire == 3 &&
                homeWorkInfo.supplyNum * 1 > 0 &&
                ((homeWorkInfo.status == 0 || homeWorkInfo.status == 2)||(homeWorkInfo.status==1&&(maxSignCount==-1||(maxSignCount>homeWorkInfo.hasSignCount))))
            " @click="clickGoClockIn" class="c-p c-mt20 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center theme-bg c-fc-white c-fs26 c-mlr-auto">
              补打卡
              <div v-if="enableCenter">
                <div class="open-tag-wrap" v-if="isSupport">
                  <wx-open-launch-weapp
                    class="launch-btn"
                    :appid="`${appid}`"
                    :username="username"
                    :path="`${path}?${wxappQuery}`"
                    @error="handleErrorFn"
                    @launch="handleLaunch"
                  >
                    <script type="text/wxtag-template">
                      <!-- 这里是为了撑开元素，让其可以被点击，不添加template会报错，添加了template不添加内容也会报错 -->
                      <div style="padding: 10000px">
                      </div>
                    </script>
                  </wx-open-launch-weapp>
                </div>
                <div v-else class="open-tag-wrap" @click="clickGoWxApp"></div>
              </div>
            </div>
            <!-- 日历打卡，打卡未开始 -->
            <div v-else-if="workType == 1 && homeWorkInfo.isExpire == 2" class="c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center c-bg-ccc c-fc-white c-fs26 c-mlr-auto">
              打卡未开始
            </div>
            <!-- 日历打卡，打卡时间已过，并且状态为未打卡-->
            <div v-else-if="
              workType == 1 &&
                homeWorkInfo.isExpire == 3 &&
                homeWorkInfo.status != 1
            " class="c-mt20 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center c-bg-ccc c-fc-white c-fs26 c-mlr-auto">
              打卡已结束
            </div>
            <!-- 强制阅读 -->
            <div v-else-if="
                   isShowTheme==1&&readTime!=0&&
                     workType == 3 &&
                     homeWorkInfo.isExpire == 1 &&
                     (homeWorkInfo.status == 0 ||
                       homeWorkInfo.status == -1 ||
                       homeWorkInfo.status == 2) &&
                     homeWorkInfo.isUnlock == 1"
              class="c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center theme-bg c-fc-white c-fs26 c-mlr-auto">阅读中({{readTime}}s)</div>
            <!-- 闯关打卡，打卡未过期，未打卡或打到一半 -->
            <div v-else-if="
              workType == 3 &&((isShowTheme==1&&readTime==0)||isShowTheme==0)&&
                homeWorkInfo.isExpire == 1 &&
                (homeWorkInfo.status == 0 ||
                  homeWorkInfo.status == -1 ||
                  homeWorkInfo.status == 2) &&
                homeWorkInfo.isUnlock == 1
            " @click="clickBerforClock" class="c-p c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center theme-bg c-fc-white c-fs26 c-mlr-auto">
              {{homeWorkInfo.buttonText}}
              <div v-if="enableCenter">
                <div class="open-tag-wrap" v-if="isSupport">
                  <wx-open-launch-weapp
                    class="launch-btn"
                    :appid="`${appid}`"
                    :username="username"
                    :path="`${path}?${wxappQuery}`"
                    @error="handleErrorFn"
                    @launch="handleLaunch"
                  >
                    <script type="text/wxtag-template">
                      <!-- 这里是为了撑开元素，让其可以被点击，不添加template会报错，添加了template不添加内容也会报错 -->
                      <div style="padding: 10000px">
                      </div>
                    </script>
                  </wx-open-launch-weapp>
                </div>
                <div v-else class="open-tag-wrap" @click="clickGoWxApp"></div>
              </div>
            </div>
            <!-- 闯关打卡，打卡时间已过，并且状态为未打卡 -->
            <div v-else-if="
              workType == 3 &&
                homeWorkInfo.isExpire == 2 &&
                (homeWorkInfo.status == 0 || homeWorkInfo.status == 2) &&
                homeWorkInfo.isUnlock == 1
            " class="c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center c-bg-ccc c-fc-white c-fs26 c-mlr-auto">
              {{homeWorkInfo.buttonText}}
            </div>
            <div v-else-if="workType == 3 && homeWorkInfo.isUnlock == 0" class="c-mt10 c-br30 c-ww320 c-hh60 c-flex-row c-flex-center c-bg-ccc c-fc-white c-fs26 c-mlr-auto">
              未解锁
            </div>
            <!-- 闯关打卡，打卡时间已过，并且状态为未打卡 -->
            <div v-else-if="
              workType == 3 &&
                homeWorkInfo.isExpire == 3 &&
                homeWorkInfo.status != 1
            " class="c-mt10 c-flex-column c-flex-center">
              <div class="c-br30 c-ww320 c-hh60 c-bg-ccc c-fc-white c-fs26 c-mlr-auto c-flex-row c-flex-center">
                闯关失败
              </div>
              <div class="theme-fc c-fs22 c-mt10">
                您的闯关打卡超过有效期{{
                  homeWorkInfo.limitDay
                }}天，过期无法继续闯关
              </div>
            </div>
          </div>
          <div v-if="homeWorkInfo.isRestDay!=1&&workType == 1 &&maxSignCount&&maxSignCount!=-1" class="c-fc-xblack c-textAlign-c c-fs20 c-pt12 c-pb32">
            今日已打卡{{homeWorkInfo.hasSignCount}}次，可打卡{{maxSignCount}}次
          </div>
          <div v-else-if="homeWorkInfo.isRestDay!=1&&workType == 1 &&maxSignCount&&maxSignCount==-1" class="c-fc-xblack c-textAlign-c c-fs20 c-pt12 c-pb32">
            今日已打卡{{homeWorkInfo.hasSignCount}}次，可打卡无限
          </div>
          <div v-if="
            workType == 3 &&
              homeWorkInfo.status != -1
          " class="c-fc-gray c-fs18 c-textAlign-c c-lh c-pt12 c-pb32">
            {{
              homeWorkInfo.isExpire == 2 && homeWorkInfo.status != 1
                ? "今日打卡次数已用完"
                : `您已完成${homeWorkInfo.hasFinish || 0}个课时`
            }}
          </div>
        </div>
      </div>
    </div>
    <div class="c-flex-row c-justify-sb c-aligni-center">
      <div class="c-flex-row c-fs28 c-fc-gray c-textAlign-c">
        <div class="c-ph24 c-mt30 c-mb30 c-p c-lh28" v-for="(item, index) in tabList" :key="index" @click="tabtag(index)" :class="tabIndex == index ? 'c-fc-xblack c-fw600' : ''">
          {{item.name}}
          <div class="c-hh16 c-ww72 theme-bg-50 c-pa c-br8 c-p-l0 c-p-r0 c-center c-p-b-6" v-if="tabIndex == index"></div>
        </div>
      </div>
    </div>
    <!-- 学员已提交作业列表 -->
    <div class="c-mh24" v-if="tabIndex==0">
      <div class="c-flex-row c-aligni-center c-justify-sb c-p c-ph24 c-pv14 theme-bg-gradient18002 c-br20 c-mb20">
        <new-clock-search-bar :day="curSelectDate" :isShowbutton="true" :placeholder="'请输入关键字搜索'"  :selectList="selectListChoose" @search="startSearch"></new-clock-search-bar>
        <div class="c-flex-row c-aligni-center c-justify-center c-fs22 c-fc-sblack">
          <div class="c-flex-row c-flex-center c-ml10" @click="clockSearchShow">
            {{day != "" || sortType !='' || startTime !='' || endTime !='' || classId !='' ? '筛选' : '全部' }}
            <span class="iconfont c-fs18 c-fc-sblack c-ml4 c-inlineblack">&#xe601;</span>
          </div>
        </div>
        <!-- <div class="c-flex-row c-aligni-center c-fs22" v-show="selectList.length > 0">
          <popup-picker :themeColor="$getThemeColor()" class="selectPicker c-mr10" title="" style="c-w100" v-model="selectItem" :data="selectList" @on-change="clickChooseSort"></popup-picker>
          <span class="iconfont c-fs18 c-fc-sgray">&#xe601;</span>
        </div> -->
      </div>
      <div class="c-bg-white c-br20 c-pt24 c-pb24 c-mb20 c-p" v-for="(item, index) in studentWorkList" :key="index" @click.stop="goStuAnswerResult(item)">
        <i v-if="item.examType == 3" class="iconfont c-pa c-p-t0 c-fs c-p-r24 c-fs24 c-p-r100 c-fc-green">&#xe829;</i>
        <div class="c-flex-row c-pl20 c-p c-aligni-center c-justify-sb">
          <div v-if="item.enableShow==0&&homeWorkInfo.isDisCheat==2" class="c-fs48 theme-fc iconfont icon-biaoqianx c-pa onlyIcon">
            <div class="c-fc-white c-fs18 c-pa c-p-t5 c-p-l20">仅老师可见</div>
          </div>
          <img @click.stop="clickGoStudyHistory(item.userId)" class="c-ww60 c-hh60 c-brp50" :src="$addXossFilter(item.headimgurl, require('@/assets/defult_head.png'))" alt="" />
          <div class="c-pl20 c-flex-grow1 c-w0">
            <div class="c-fs24 c-flex-row c-aligni-center c-justify-sb">
              <div class="c-flex-row">
                <span class="c-pr20 c-maxw160 c-text-ellipsis1">{{ item.nickname }}</span>
                <span v-if="item.isTop" class="c-fs18 c-ww60 c-flex-row c-lh c-flex-center theme-bg c-fc-white c-br6 c-mr12">置顶</span>
                <span v-if="item.isHot" class="c-fs18 c-ww60 c-flex-row c-lh c-flex-center theme-fc theme-bd1 theme-bg-10 c-br6">精选</span>
              </div>
              <!-- <span v-if="item.type == 3 && item.aiNum > 1" @click.stop="showAiAnswerContent(item)" class="c-pl20  box-analyze theme-bg-10 c-flex-row c-flex-center c-fs18 theme-fc">详情<i
                class="iconfont c-fs12 theme-fc">&#xe60e;</i>
              </span> -->
            </div>
            <div class="c-flex-row c-aligni-center c-justify-sb c-mt4">
              <div class="c-flex-row c-aligni-center">
                <div v-if="(item.type == 1||item.type == 4) && item.rank !== null && item.rank!=0" class="c-flex-row c-flex-center">
                  <img v-for="index in 5" :key="index" class="c-ww24 c-hh24 c-mr4" :src="
                    index <= item.rank
                      ? require('@/assets/i/wap/clockIn/star_s.png')
                      : require('@/assets/i/wap/clockIn/star_d.png')
                  " alt="" />
                </div>
                <span v-if="(item.type == 1||item.type == 4) && item.rank !== null && item.rank!=0" class="theme-fc c-pl10 c-pr10 c-fs20">{{ item.rank * 20 }}分</span>
                <div v-if="workType == 1" class="c-fs18 c-fc-gray">
                  已打卡{{ item.finishNum }}天
                </div>
                <div v-else-if="workType == 2" class="c-fs18 c-fc-gray">
                  已完成{{ item.finishNum }}个作业
                </div>
                <div v-else class="c-fs18 c-fc-gray">
                  已打卡{{ item.finishNum }}课时
                </div>
              </div>
            </div>
          </div>
          <i class="iconfont c-fc-gray c-pr24 c-fs32" v-if="(topData.userId==item.userId)&&((item.isDisAgainSign)||(item.isAnalyze && item.type == 1)||item.enableDelete==1)" @click.stop="calcOperation(item,index)">&#xe7be;</i>
        </div>
        <!-- 作业内容 -->

        <clock-aswer-content
          @clickCom="clickCom"
          @clickZan="clickZan"
          @clickPlayAudio="clickPlayAudio"
          @clickShowVideo="clickShowVideo"
          :isAnalyze="0"
          :playAduioSrc="playAduioSrc"
          :homeworkType="item.type"
          :aswerInfo="item"
          :aswerIndex="index"
          :isTeacher="homeWorkInfo.isTeacher">
        </clock-aswer-content>
      </div>
      <loading-status-tem :dataStatus="dataStatus" noDataText="暂无打卡记录"></loading-status-tem>
    </div>
    <div v-if="tabIndex == 1" class="c-ph24">
      <div class="c-flex-row c-justify-sb c-aligni-center c-mb20" v-if="workType == 2">
        <div class="c-fs22 c-fc-sgray">全部作业：<span class="c-fc-xblack">{{mainData.allWork}}</span> 个  ｜   已完成：<span class="c-fc-xblack">{{mainData.finishNum}}</span> 个</div>
      </div>
      <div class="c-flex-row c-aligni-center c-justify-sb c-p c-ph24 c-pv14 theme-bg-gradient18002 c-br20 c-mb20" v-if="((workType == 1&&topData.isSingleTheme != 1)||workType == 2)">
        <new-clock-search-bar :isShowbutton="true" :placeholder="'请输入关键字搜索'" @search="startselecthw"></new-clock-search-bar>
        <div class="c-flex-row c-aligni-center c-fs22" v-show="selecthw.length > 0">
          <popup-picker cancel-text="取消" confirm-text="确定" :themeColor="$getThemeColor()" class="selectPicker c-mr10" title="" style="c-w100" v-model="selecthwItem" :data="selecthw" @on-change="clickselecthw"></popup-picker>
          <span class="iconfont c-fs18 c-fc-sgray">&#xe601;</span>
        </div>
      </div>
      <div class="c-flex-row c-justify-sb c-aligni-center c-mb20" v-if="workType == 3">
        <div class="c-fs22 c-fc-sgray">总课时：<span class="c-fc-xblack">{{mainData.allWork}}</span> 个  ｜   已闯关：<span class="c-fc-xblack">{{mainData.finishNum}}</span> 个</div>
      </div>
      <div class="theme-bg-gradient18002 c-ph20 c-pt20 c-pb40 c-br20" v-if="(workType == 1 || workType == 2)&&homeWorkList&&homeWorkList.length != 0">
        <div v-for="(item, index) in homeWorkList" :key="index" @click="goToDiary(item)">
          <div class="c-mt20 c-pv30 c-ph20 c-bg-white c-br20 c-p c-text-hidden">
            <!-- <div class="c-fs80 c-pa c-p-isExpire iconfont c-fc-sgray" v-if="">&#xe999;</div> -->
            <div class="c-fs18 c-pa c-p-typeQueMap theme-fc theme-bg-10 c-ph14">{{typeQueMap[item.type]}}</div>
            <div class="c-flex-row c-justify-sb c-aligni-center">
              <div class="c-fs28 c-fc-xblack c-text-ellipsis1 c-ww380">{{item.name}}</div>
              <div class="c-fs20 c-ph14 c-pv4 c-br18" v-if="topData.isSingleTheme != 1"
                :class="item.isExpire == 2 ? 'noExpire' : (item.status == 1 ? 'doit':(item.isExpire == 3? 'nodoit':''))">
                <!-- {{item.isStart == 0 ? '未开始' : (item.status == 1 ? '已完成':'')}} -->
                {{
                  item.status == 1 ? '已完成' : (item.isExpire == 2 ? '未开始' :
                    (item.isExpire== 3 ? '已过期' : ''))
                }}
              </div>
            </div>
            <div class="c-mt18 c-fs20 c-fc-gray c-flex-row c-justify-sb c-aligni-center">
              <div>{{workType == 1? item.startDay:item.startTime+' 至 '+item.endTime}}</div>
              <div>{{item.hasMan}}人打卡</div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="workType == 3">
        <div class="theme-bg-gradient18002 c-ph20 c-pv20 c-br20">
          <div class="c-mt20 c-pv30 c-ph20 c-bg-white c-br20 c-flex-row c-justify-sb c-aligni-center" v-for="(item,index) in homeWorkList" :key="index" @click="goToDiary(item,item.reorder)">
            <div>
              <div v-if="item.isUnlock" class="c-bg-sgray c-brp50 c-ww64 c-hh64 c-flex-row c-flex-center">
                <i class="iconfont c-fc-gray c-fs32">&#xe848;</i>
              </div>
              <div v-else class="c-bg-sgray c-brp50 c-ww64 c-hh64 c-flex-row c-flex-center">
                <i class="iconfont c-fc-gray c-fs32">&#xe84d;</i>
              </div>
            </div>
            <div class="c-flex-grow1 c-ml18">
              <div class="c-fs28 c-fc-xblack c-text-ellipsis1">第{{item.reorder}}课时</div>
              <div class="c-mt16 c-fs20 c-fc-gray c-flex-row c-justify-sb c-aligni-center">
                <div>{{item.hasMan}}人已完成</div>
              </div>
            </div>
            <div class="c-fs22" :class="item.isUnlock ? 'c-fc-green' : item.reorder-1 == hasBreak ? 'theme-fc':'c-fc-sgray'">{{item.isUnlock ? '已闯关' : item.reorder-1 == hasBreak ? '待闯关':'未闯关'}}</div>
          </div>
        </div>
      </div>
      <loading-status-tem :dataStatus="dataStatus" noDataText="暂无记录"></loading-status-tem>
    </div>
    <div v-if="tabIndex == 2" class="c-ph24">
      <div class="c-bg-white c-pt40 c-br20 c-text-hidden" v-if="pupilList.length > 0">
        <div class="c-ph22 c-pb40 c-bg-white c-flex-row c-aligni-center" v-for="(item, index) in pupilList" :key="index">
          <img class="c-ww68 c-hh68 c-brp50" :src="$addXossFilter(item.headimgurl, require('@/assets/defult_head.png'))" alt="" />
          <div class="c-fs20 c-fc-gray c-flex-column c-flex-grow1 c-ml20">
            <div class="c-fs24 c-fc-xblack">{{item.nickname}}{{item.realName ? '(' + item.realName + ')' : ''}}</div>
            <div class="c-mt6">{{item.createdAt}}加入</div>
          </div>
        </div>
      </div>
      <loading-status-tem :dataStatus="dataStatus" noDataText="暂无记录"></loading-status-tem>
    </div>
    <!-- 视频播放器 -->
    <video-popup :showVideo="showVideo" @clickCloseVideo="clickCloseVideo" :videoSrc="currentVideoObj.videoSrc" :m3u8Url="currentVideoObj.m3u8Url"></video-popup>
    <!-- 非教师评论 -->
    <clock-comment-com  :enHwId="enHwId" :clockInId="clockInId"
      :enDate="enDate" :enableLongAudio='enableLongAudio' @clickShowVideo="clickShowVideo" :comType="comType" :isTeacher="homeWorkInfo.isTeacher" :playAduioSrc="playAduioSrc" :showCommentModal="showComInput" :inputCom="inputCom" :replyName="replyName"
      :curComId="curComId" :replyId="replyId" :commentId='commentId' :imgData="imgData" @commentSuccess="commentSuccess" @clickPlayAudio="clickPlayAudio" @cleanPlayAudioUrl="cleanPlayAudioUrl"></clock-comment-com>
    <!-- 教师评论(评分和设置精选) -->
    <clock-tea-comment-com :enHwId="enHwId" :curSelectDate="curSelectDate" :curId="topData.hwId"
      :enDate="enDate" :teacher="1" :clockInId="clockInId" :enableLongAudio='enableLongAudio' :playAduioSrc="playAduioSrc" :showTeaCommentModal="showTeaCommentModal" :workType="workType" :resultIndex="resultIndex" :resultInfo="resultInfo" :imgData="imgData"
      @commentSuccess="commentSuccess" @clickPlayAudio="clickPlayAudio" @clickShowVideo="clickShowVideo" @cleanPlayAudioUrl="cleanPlayAudioUrl"></clock-tea-comment-com>
    <!-- 日签 -->
    <day-sign ref="daysign" :showSignDay="showSignDay" :signDayInfo="signDayInfo" @closeSignDay="closeSignDay" @canvasOver="canvasOver"></day-sign>
    <!-- 打卡证书 -->
    <certificate-com ref="certificate" :bigType="1" :prodId="clockInId" :prodType="41" :showCertificate="showCertificate" :certInfo="certificateInfo" :showReward="homeWorkInfo.gitType == 2&&homeWorkInfo.hasGetCoupon==0&&homeWorkInfo.isEnd==1" @getReward="getReward" @closeCertificate="closeCertificate">
    </certificate-com>
    <!-- 获得积分 -->
    <show-integrate :showIntegrate="showIntegrate" :integrateCount="integrateCount" v-if="showIntegrate" @closeShareInt="closeShareInt"></show-integrate>
    <!-- 切换身份 -->
    <!-- <div v-if="homeWorkInfo.isTeacher == 1 || homeWorkInfo.isTeacher == 2" class="c-box-shadow9 c-flex-row c-ph24 c-aligni-center c-justify-sb c-bd-t1 c-hh88 c-pf c-p-b0 c-w100 c-maxw640 c-bg-white">
      <div class="c-hh64 c-fs26 c-flex-column c-aligni-center c-fc-white c-justify-sa theme-bg c-w100 c-br32" :class="isShowClockSearch? 'c-pz-1' : ''" @click="clickChangeRole">切换{{ homeWorkInfo.isTeacher == 1 ? "学员" : "教师" }}</div>
    </div> -->
    <!-- 优惠券弹窗 -->
    <coupon-modal v-if="showCouponDialog" adName="毕业福利" :day="curSelectDate" :signColId='clockInId' :adCoupon="adCoupon" recordType="9" :showCouponDialog.sync="showCouponDialog"></coupon-modal>

    <cj-popup v-model="showAiAnswer" round>
      <article class="c-ww570 c-textAlign-l c-mt20 c-bg-white c-br20 c-ph20 c-pt30 c-pb40">
        <h2 class="c-pb40 c-fs30 c-fw-b">答题卡</h2>
        <section v-if="curAiAnswerInfo">
          <clock-aswer-ai :clockInId='clockInId' :examMainId="curAiAnswerInfo.examMainId" :curHwId="curAiAnswerInfo.hwId" :totalNum="curAiAnswerInfo.content" :showAiResutl="showAiAnswer"></clock-aswer-ai>
        </section>
      </article>
    </cj-popup>

    <cj-popup v-model="showAccountQcode" round>
      <div class="c-pv50 c-ww520">
        <div class="c-fs28 c-fw-b c-textAlign-c">关注公众号</div>
        <div class="c-fs24 c-textAlign-c c-pv30">获得打卡课程提醒</div>
        <div>
          <img :src="$addXossFilter(mpQrcodeImg)" alt="" class="c-ww250 c-hh250 c-m-0auto" />
        </div>
        <div class="c-pt20 c-fs20 c-fc-gray c-textAlign-c">
          长按识别二维码&nbsp;&nbsp;关注公众号
        </div>
      </div>
    </cj-popup>
    <cj-actionsheet v-model="myOperationShow" :item-list="operationMenu" @choose="clickOperationMenu" show-cancel></cj-actionsheet>
    <!-- 作业选择 -->
    <cj-popup v-model="isShowhw" :closeable="true" title="选择提交的作业" position="bottom" round>
      <div class="c-flex-column c-minh50vh c-bg-white">
        <div class="c-flex-grow1 c-content-scroll c-pb30">
          <div v-for="(item, index) in unFinishedHwList" :key="index" @click="clickGoClockIn(item)">
            <div class="c-pv24 c-ph20 c-bg-white c-br20 c-p c-text-hidden">
              <div class="c-flex-row c-justify-sb c-aligni-center">
                <div class="c-fs28 c-fc-xblack c-text-ellipsis1">{{item.name}}</div>
              </div>
              <div class="c-mt18 c-fs20 c-fc-gray c-flex-row c-justify-sb c-aligni-center">
                <div>{{item.startTime}} 至 {{item.endTime}}</div>
                <div>{{item.hasMan}}人完成</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </cj-popup>
    <clock-search :day="day" :isStudent="homeWorkInfo.isTeacher==0?1:0" :workType='workType' @sureSearch='sureSearch' :clockInId="clockInId" :isShowClockSearch="isShowClockSearch" @clockSearchHide="clockSearchHide"></clock-search>
    <clock-go-wx :showAialogPop="showAialogPop" :clockInInfo="topData" @closeAialogPop="closeAialogPop"></clock-go-wx>
    <comfirm-com :showPassword.sync="showPassword" :pwTip="homeWorkInfo.pwTip" text="输入密码继续打卡" @submitPassword="clickAddEnter"></comfirm-com>
    <cj-popup v-model="isShowTip" :closeable="false" position="center" round @closed="closeTip">
      <div class="c-p">
        <div class="c-ww500"><img src="@/assets/i/wap/clockIn/tip.png" alt=""></div>
        <div class="c-ww240 c-hh56 c-lh56 c-textAlign-c c-br28 onlyBtn c-pa c-p-b40 c-p-l0 c-p-r0 c-center c-fs24 c-fc-white" @click="closeTip">我知道了</div>
      </div>
    </cj-popup>
    <div class="c-ph24 c-pf c-p-b20 c-w100" v-if="enableCalRemindFee">
      <div class="c-w100 c-text-hidden" >
        <!-- 续费提醒 -->
        <div class="mod-renewal c-flex-row c-aligni-center c-justify-sb">
          <div class="c-flex-row">
            <i class="iconfont c-fc-xlblown c-mr12 c-fs30 c-mt2">&#xe6cd;</i>
            <div class="c-fc-xlblown">
              <p class="c-fw600 c-fs26">打卡即将到期，剩余{{diffDay}}天</p>
              <p class="c-fs20 c-mt10">及时续费，以免错过精彩内容~</p>
            </div>
          </div>
          <div class="renewal-btn c-fs22 c-flex-row c-justify-center c-aligni-center c-fc-white" @click="goToBuy">立即续费</div>
          <div @click="closeRenewNotice" class="renew-notice"><i class="iconfont c-fs20 c-fc-gray">&#xe8fd;</i></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {PopupPicker } from 'ckjrweb-mp-ui/src/components/index';
import { utilJs, wxUtilJs } from "@/utils/common.js";
import ComfirmCom from "@/components/templates/common/comfirmCom.vue";
import DaySign from "./daySign.vue";
import certificateCom from "./certificateCom.vue";
import clockAswerAi from "@/components/templates/clockIn/clockAswerAi.vue";
import ClockCourseDetailCom from "@/components/templates/clockIn/clockCourseDetailCom.vue";
import clockAswerContent from "@/components/templates/clockIn/clockAswerContent.vue";
import clockCommentCom from "@/components/templates/clockIn/clockCommentCom.vue";
import clockTeaCommentCom from "@/components/templates/clockIn/clockTeaCommentCom.vue";
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import showIntegrate from "@/components/templates/common/showIntegrate.vue";
import couponModal from "@/components/templates/couponModal.vue";
import videoPopup from "@/components/templates/common/videoPopup.vue";
import { getBindPhoneSetting } from "@/utils/checkUnBindPhone.js";
import clockSearch from "@/components/templates/clockIn/clockSearch.vue";
import NewClockSearchBar from "@/components/templates/common/newClockSearchBar.vue";
import clockGoWx from "@/components/templates/clockIn/clockGoWx.vue";
const ONE_DAY_TIMES_TAMP = 24 * 60 * 60 * 1000; //一天的时间毫秒数
//const clientW = document.documentElement.clientWidth > 640 ? 640 : document.documentElement.clientWidth; //屏幕宽度
//const videoH = (clientW / 320) * 180; //视频高度
let isLoading = false;
let pageIndex = 1;
let LIMIT = 10;
let clockInId = ""; //当前作业ID
let hasRead = '';//推送来源
let curComIndex = ""; //当前评论的下标
let myCurComIndex = '';//当前我的评论的下标
let readTimeContain = null
export default {
  name: "HomeWork",
  components: {
    ComfirmCom,
    clockAswerAi,
    ClockCourseDetailCom,
    clockAswerContent,
    clockCommentCom,
    clockTeaCommentCom,
    DaySign,
    clockGoWx,
    loadingStatusTem,
    showIntegrate,
    certificateCom,
    couponModal,
    videoPopup,
    PopupPicker,
    NewClockSearchBar,
    clockSearch
  },
  props: [],

  beforeRouteLeave(to, from, next) {
    //当有评论弹窗的时候，后退就关闭弹窗,因为后退会把history历史栈后退一个，所以要添加回去
    if (
      (this.showComInput || this.showTeaCommentModal || this.showVideo) &&
      to.path != "/" &&
      to.path != "/homePage/spread/spreadIndex" &&
      to.path != "/member/vip/vipUpNew"
    ) {
      this.showComInput = false;
      this.showTeaCommentModal = false;
      if (this.showVideo) {
        this.showVideo = false;
      }
      history.pushState(
        null,
        null,
        `${window.location.href.split("#")[0]}#${from.fullPath}`
      );
    } else {
     /* if (to.path == '/homePage/login/bindMobile') {
        let curClockId = clockInId * 1;
        if (localStorage.getItem("certArray")) {
          let localCertArr = JSON.parse(localStorage.getItem("certArray"));
          if (localCertArr.includes(curClockId)) {
            localCertArr.splice(localCertArr.indexOf(curClockId), 1)
            if (localCertArr && localCertArr.length > 0) {
              localStorage.setItem("certArray", JSON.stringify(localCertArr));
            } else {
              localStorage.removeItem("certArray");
            }
          }
        }
      }*/
      next();
    }
  },
   watch: {
  },
  data() {
    return {
      isShowTip:false,
      topData:null,
      curHwId:'',
      enHwId:'',
      enDate :'',
      curScollTop:0,
      curScollTopFlag:true,
      theme: localStorage.getItem("colorName")
        ? localStorage.getItem("colorName")
        : "mb5_default",
      workType: "2",
      cfg: JSON.parse(localStorage.getItem("cfg")),
      dataStatus: "HAS_MORE_DATA",
      playAduioSrc: "",
      sortType: 0, //排序
      sortTypeLocal:1, //排序暂存
      showSignDay: false, //显示日签
      showVideo: false, //显示视频播放器
      isCanvasOver: false, //是否绘制日签完成
      homeWorkInfo: {},
      showComInput: false, //显示评论输入框
      showTeaCommentModal: false, //显示教师评论输入框
      searchName: "",
      searchhwName:"",
      typeQueMap: {
        1: "简答题",
        2: "非简答题",
        3: "AI语音",
        4: "表单",
        5: "非简答题"
      },
      resultInfo: {},
      resultIndex: -1,
      curComId: "", ///当前评论ID
      inputCom: "", //评论的输入内容
      replyId: "", //回复人的昵称
      commentId:"", //回复的内容id
      replyName: "", //回复人的ID
      studentWorkList: [], //提交的作业列表
      signDayInfo: {}, //日签信息
      myCalendarList: [], //我的日历打卡
      mySignList: [], //已打卡记录
      curSelectDate: "", //当前选择的日历打卡日期
      curSelectYearMonth: "", //当前选择的年月
      showCertificate: false, //显示证书
      showStudentWorkList: false, //显示学员打卡内容
      certificateInfo: {},
      showPassword: false,
      ttId: "", //营期ID
      tpId: "", //环节ID
      tlId: "", //课时ID
      showIntegrate: false, //获取积分提示
      integrateCount: 0,
      showCouponDialog: false,
      showAiAnswer: false,
      curAiAnswerInfo: null,
      adCoupon: [],
      showReward: false,
      getAlready: false,
      isFirstJoin: 0,
      imgData: {},
      noticesToast: false,
      mpQrcodeImg: "",
      showAccountQcode: false, //显示二维码
      subscribeStatus: 0, //是否开启通知
      comType: 1, //是否教师评论教师
      refereeId:'',
      clockInId:'',
      currentVideoObj: {},
      selectListChoose: [["昵称", "内容"]],
      selectList: [["按默认", "按点赞", "按精选"]],
      selecthw: [["正序", "倒序"]],
      selecthwItem:[],
      selectItem:[],
      searchType:'',
      classList: [{
        classId: '',
        name: "所有成员"
      }], //分组
      showClassListName:'所有成员',
      day:'', //是打卡日期,
      hwId:'',
      sort:'', //1打卡时间降序 2打卡升序 3被点评数降序 4被点评升序  5被点赞数降序 6被点赞数升序
      type:'', //1已打卡 2未打卡学员
      startTime:'', //开始时间
      endTime:'', //结束时间
      classId:'', //分组id
      showClassListid:'',
      showClistType:false,
      showwite:false,
      showAll:false,
      myOperationShow: false,
      operationMenu: {},
      showIconList: true,
      operationMenuLength: 0,
      showDayCardfast:true,
      bindPhoneSetting: null,
      themeId: '', //来源圈子任务的主题id
      tabList: [
        {name:"日记"},
        {name:"主题"},
        {name:"成员"}
      ],
      tabIndex: 0,
      pupilList:[],
      unFinishedHwList:[],
      isShowhw:false,
      mainData: {
        allWork: 0,
        finishNum: 0
      },
      sorthwType:1,
      levelNum:[],
      hasBreak:0,
      finishPeopleNum:0,
      isShowClockSearch:false,
      showAialogPop : false, //是否弹窗提醒：true=是；false=否
      enableBanner: 0, //是否横幅提醒：1=是；0=否
      enableCenter:0, //是否互动入口跳转小程序：1=是；0=否
      appid:'wxc99b13f1a0b51048',
      wxappQuery: "",
      path:'/pages/clockIn/homeWorker/index',
      isSupport:false,
      first:0,
      customPointName: localStorage.getItem("customPointName"),
      maxSignCount:0,
      isPrivate:0,
      isShowTheme:0,
      readTime:'',
      enablePreview:1,
      enableLongAudio:0,
      enableCalRemindFee:0,
      diffDay:0
    };
  },
  created() {
    utilJs.appShare(this);
    this.isSupport = localStorage.getItem('isWxApp') != 1;
  },
  methods: {
    goToBuy() {
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/clockInDetail",
        query: {
          clockInId: clockInId
        }
      });
    },
    closeTip() {
      this.isShowTip = false
    },
    closeRenewNotice() {
      utilJs.postMethod(`${global.apiurl}signCard/closeRemindFee`, {
        signColId:clockInId
      }, (res) => {
        this.enableCalRemindFee = false
      })
    },
    getBaseConfig() {
      let postUrl = this.workType == 1 ? `${global.apiurl}signCard/getBaseConfig?signColId=${clockInId}&day=${this.curSelectDate}` : `${global.apiurl}signCard/getBaseConfig?signColId=${clockInId}&hwId=${this.curHwId}`;
      utilJs.getMethod(postUrl, (res) => {
        this.isDisCheat = res.isDisCheat
        this.maxSignCount = res.maxSignCount
        this.isPrivate = res.isPrivate
        this.isShowTheme = res.isShowTheme
        this.readTime = res.readTime
        this.diffDay = res.diffDay
        this.enableCalRemindFee = res.enableCalRemindFee
        if (this.workType == 1) {
          this.getCalendarHomeWork();
        } else {
          this.getHomeWorkDatail();
        }
        if (this.workType == 3) {
          this.getLevelNum()
        }
      //   signColumns：
      // 1. maxSignCount
      // 2.isDisAgainSign  //是否允许重新打卡 1：允许 0：不允许
      // 3.isDisCheat  //防作弊模式 1：开启 0：关闭； 2=学生自定义
      // 4.isPrivate   '是否开启私密 :1=是；0=否；',

      // signColumnExtras：
      // isShowTheme  是否显示主题 1是 0否
      // readTime  '阅读时长，分:秒,  如 20:21'
        this.enablePreview = res.enablePreview
        this.enableLongAudio = res.enableLongAudio
      });
    },
    //进入统计
    clickGoTottal() {
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/clockInTottal",
        query: {
          clockInId: clockInId
        }
      });
    },
    // 获取头部打卡信息
    topDetail() {
      let getUrl = `signCard/topDetail/${clockInId}?hasRead=${hasRead}`
      utilJs.getMethod(
        global.apiurl + getUrl,
        (res) => {
          console.log(res)
          if ((res.status == 0 && (!res.hasPermission || res.isBuy == 0)) || res.status == -1) {
            this.$routerGo(this, "replace", {
              path: "/error/emptyPage",
              query: {
                from: "",
                info: res.status == -1 ? "该打卡作业本已删除，请联系管理员！" : "该打卡作业本已下架，请联系管理员！"
              }
            });
            return
          }
          if (!res.hasPermission && !(res.type == 3 && !res.hasPermission && res.isExperienceLesson)) {
            let q = {clockInId: clockInId}
            if (this.refereeId && this.refereeId != "undefined" && this.refereeId != "null") {
              q.refereeId = this.refereeId;
            }
            this.$routerGo(this, "replace", {
              path: "/homePage/clockIn/clockInDetail",
              query: q
            });
            return
          }
          this.workType = res.type
          this.topData = res
          this.curHwId = this.workType == 3 ? res.curHwId : this.curHwId ? this.curHwId : res.hwId
          if (this.workType == 1 ) {
            this.tabList = [
              {name:"日记"},
              {name:"主题"},
              {name:"成员"}
            ]
          } else if (this.workType == 2 ) {
            this.tabList = [
              {name:"日记"},
              {name:"作业"},
              {name:"成员"}
            ]
          } else if (this.workType == 3 ) {
            this.tabList = [
              {name:"日记"},
              {name:"关卡"},
              {name:"成员"}
            ]
          }
          let fistTip = localStorage.getItem("fistTip") || ''
          if (fistTip == '' && (res.isTeacher == 1 || res.isTeacher == 2)) {
            this.isShowTip = true
            localStorage.setItem("fistTip", 1)
          }
           this.day = res.isTeacher == 1 || res.isTeacher == 2 ? '' : this.curSelectDate || ""
          this.getBaseConfig()
          var href = window.location.host.indexOf(".wx.ckjr001.com") != -1 ? "wx.ckjr001.com" : window.location.host;
          let env = ''
          if ((href == 'kptest.ckjr001.com' || href == 'kptest2.ckjr001.com' || href == 'kptest3.ckjr001.com') && window.location.href.includes('testApiUrl')) {
              env = 1
          }
          switch (this.topData.type) {
            case 1:
              //日历打卡,若当前日期不在开始日期和结束日期之间，则从开始日期进入，否则从当前日期进入
              let startTimeTamp = new Date(`${this.topData.startTime} ${this.topData.startHour}`.replace(/-/g, "/")).getTime();
              let endTimeTamp = new Date(`${this.topData.endTime} ${this.topData.endHour}`.replace(/-/g, "/")).getTime();
              let nowTimeTamp = new Date().getTime();
              let curTime = utilJs.dateFormat(nowTimeTamp);
              // if (this.topData.isSingleTheme == 2) {
              //   curTime = this.topData.startDay.split(' ')[0]
              // } else {
                //日历打卡,若当前日期不在开始日期和结束日期之间，则从开始日期进入，否则从当前日期进入
                if (nowTimeTamp < startTimeTamp || nowTimeTamp > endTimeTamp) {
                  curTime = this.topData.startTime;
                }
              // }
              this.wxappQuery = `workType=1&fromDetail=1&cId=${localStorage.getItem("companyId")}&clockInId=${this.topData.signColId}&curSelectDate=${curTime}&env=${env}`
              break;
            case 2:
              this.wxappQuery = `workType=2&fromDetail=1&cId=${localStorage.getItem("companyId")}&clockInId=${this.topData.signColId}&curId=${this.topData.hwId}&env=${env}`
              //作业打卡，如果超过一个作业，则进入作业列表，否则进入作业详情
              break;
            case 3:
              this.wxappQuery = `workType=3&fromDetail=1&cId=${localStorage.getItem("companyId")}&clockInId=${this.topData.signColId}&curId=${this.topData.hwId}&env=${env}`
              //闯关打卡
              break;
          }
          // this.wechatShare();
        }
      );
    },
    showAllMyResult() {
      this.showAll = true
    },
    //简答题答题长图页
    clickLookShortAnswerResult(index) {
      this.$routerGo(this, "push", {
          path: "/homePage/clockIn/shortAnswerResult",
          query: {
            clockInId: clockInId,
            curHwId : this.homeWorkInfo.hwId,
            hasRead : hasRead,
            curSelectDate:this.curSelectDate,
            ttId: this.ttId,
            tpId: this.tpId,
            tlId: this.tlId,
            ckFrom: this.ckFrom,
            isTraining:this.isTraining,
            workType:this.workType,
            examMainId: this.homeWorkInfo.myResult[index].examMainId,
          }
        });
    },
    //开启通知
    clickSubscribeNotices() {
      if (isLoading) {
        return;
      }
      this.noticesToast = false;
      let status = this.subscribeStatus == 1 ? -1 : 1;
      let that = this;
      isLoading = true;
      utilJs.postMethod(
        global.apiurl + "signCard/subscribeNotices/" + clockInId,
        { status: status },
        function (res) {
          that.subscribeStatus = status == -1 ? -1 : 1;
          if (res.mpQrcode) {
            that.mpQrcodeImg = res.mpQrcode;
            that.showAccountQcode = true;
            isLoading = false;
          } else {
            let toastText = status == -1 ? "已关闭通知" : "已开启通知";
            Vue.prototype.$showCjToast({
              text: toastText,
            });
            isLoading = false;
          }
        },
        (failRes) => {
          isLoading = false;
        }
      );
      //
    },
    updateShowCerStatus(id) {
      utilJs.postMethod(
          global.apiurl + "signCard/updateShowCerStatus",
          {cerId:id},
          function (res) { }
        );
    },
    setProgress: function () {
      let data = {
        ttId: this.ttId, //营期ID
        tpId: this.tpId, //环节ID
        tlId: this.tlId, //课时ID
        ratio: 100, //完成进度0-100
        duration: 0,
      };
      if (this.ttId && this.tpId && this.tlId) {
        utilJs.postMethod(
          global.apiurl + "k12/trainings/progress",
          data,
          function (res) { }
        );
      }
    },
    showAiAnswerContent(itemInfo) {
      this.curAiAnswerInfo = itemInfo;
      this.showAiAnswer = true;
    },
    //获取分组
    getClassList () {
      return new Promise((resolve, reject) => {
        let postUrl = `${global.apiurl}signCard/classList/${clockInId}`;
       utilJs.getMethod(postUrl, (res) => {
         this.classList = [...this.classList, ...res]
          resolve()
        }, () => {
          isLoading = false;
          reject()
        });
      })
    },
    // 获取毕业福利(优惠券)
    getReward: function () {
      let postUrl = `${global.apiurl}signCard/couponShow/${clockInId}`;
      utilJs.getMethod(
        postUrl,
        (res) => {
          if (res.length == 0) {
            this.$showCjToast({
              text: "暂无可用优惠券领取",
              type: "error"
            });
            return;
          }
          this.showCouponDialog = true;
          this.adCoupon = res;
        },
        (failRes) => {
          isLoading = false;
        }
      );
    },
    clickGoClockDetail() {
      if (this.fromDetail == 1) {
        this.$router.go(-1);
      } else {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/clockInDetail",
          query: {
            clockInId: clockInId
          }
        });
      }
    },
    //输入密码后添加记录
    clickAddEnter(pwd = '') {
      if (isLoading) {
        return;
      }
      isLoading = true;
      let data = {
        signColId: clockInId,
        type: 2,
        password: pwd
      };
      utilJs.postMethod(
        global.apiurl + "signCard/buildRelated",
        data,
        (res) => {
          isLoading = false;
          this.initData();
          this.topDetail()
        },
        (failRes) => {
          isLoading = false;
        }
      );
    },
    //讲师切换身份 1 讲师 2 学员
    clickChangeRole() {
      let postData = {
        signColId: clockInId,
        idType: this.homeWorkInfo.isTeacher == 1 ? 0 : 1 // 1：教师端 0：学生端
      };
      utilJs.postMethod(
        global.apiurl + "signCard/switchId",
        postData,
        (res) => {
          if (postData.idType == 1) {
            this.$routerGo(this, "replace", {
              path: `/homePage/clockIn/teaHomeWorker?fromDetail=1&clockInId=${clockInId}`
            });
            return
          }
        }
      );
    },
    showWidthfn() {
      this.showwite = true
    },
    clockSearchShow() {
      this.isShowClockSearch = true
    },
    clockSearchHide() {
      this.isShowClockSearch = false
    },
    sureSearch(selectItemTime, selectItemsort, starTime, endTime, classId, hwId) {
      if (this.workType == 1) {
        if (selectItemTime == '全部主题') {
          this.day = ''
        } else {
          this.day = selectItemTime
        }
      }
      pageIndex = 1; //页数
      this.sortType = selectItemsort; //是否点评 1已点评 2未点评 3精选 4非精选
      this.startTime = starTime; //开始时间
      this.endTime = endTime; //结束时间
      this.classId = classId; //分组id
      this.hwId = hwId
      this.studentWorkList = [];
      this.$store.commit('updateClockCalendar', '');
      this.getStudentWorkList()
    },
    startSearch(searchText) {
      this.searchName = searchText.searchValue;
      let si = searchText.selectItem;
      pageIndex = 1;
      if (si == "昵称") {
        this.searchType = 1
      } else if (si == "内容") {
        this.searchType = 2
      }
      this.getStudentWorkList();
    },
    //进入闯关列表
    clickGoLevelList() {
      if (!this.homeWorkInfo.hasPermission) {
        return;
      }
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/levelList?clockInId=" + clockInId
      });
    },
    cleanPlayAudioUrl() {
      this.playAduioSrc = "";
      document.getElementById("audio").src = this.playAduioSrc;
    },
    getCurYearMonth(date) {
      const arr = date.split('-')
      const year = arr[0]
      const month = arr[1]
      this.curSelectYearMonth = year + '年' + month + '月'
    },
    //进入日历
    clickGoCalendar() {
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/clockCalendar",
        query: {
          clockInId: clockInId
        }
      });
    },
    //点击日期
    clickChangeDate(index) {
      if (this.myCalendarList[index].type == 0) {
        return;
      }
      this.showIconList = false
      this.curSelectDate = this.myCalendarList[index].date;
      this.day = this.homeWorkInfo.isTeacher ? '' : this.curSelectDate
      this.getCurYearMonth(this.curSelectDate)
      let newUrl = `${
        window.location.href.split("#")[0]
        }#/homePage/clockIn/stuHomeWork?workType=1&clockInId=${clockInId}&curDate=${
        this.curSelectDate
        }`;
      //解决进入排行榜，学习记录，邀请卡的时候回来导致页面是第一次进来的作业
      history.replaceState("stuHomeWork", "", newUrl);
      this.initData();
      this.getCalendarHomeWork();
    },
    //点击显示视频
    clickShowVideo(videoSrc, m3u8Url) {
      this.showVideo = true;
      this.currentVideoObj = {videoSrc, m3u8Url}
    },
    //点击关闭视频
    clickCloseVideo() {
      if (this.showVideo) {
        this.showVideo = false;
      }
    },
    //点击上一个
    clickGoPre() {
      if (this.homeWorkInfo.beforeId) {
        this.curHwId = this.homeWorkInfo.beforeId;
        let newUrl = `${
          window.location.href.split("#")[0]
          }#/homePage/clockIn/stuHomeWork?workType=${
          this.workType
          }&clockInId=${clockInId}&curId=${this.curHwId}&isFirstJoin=${
          this.isFirstJoin
          }`;
        //解决进入排行榜，学习记录，邀请卡的时候回来导致页面是第一次进来的作业
        history.replaceState("homework", "", newUrl);
        this.initData();
        this.topDetail()
      }
    },
    //日签
    clickShowSign() {
      console.log(this.topData, '日签')
      if ((this.workType == 1 || this.workType == 3) && this.homeWorkInfo.status != 1) {
        this.$showCjToast({
          text: "先打卡才能生成日签",
          type: "warn",
        });
        return
      }
      if ((this.workType == 1 || this.workType == 3 ) &&
        this.homeWorkInfo.status == 1 &&
        this.homeWorkInfo.dayCardStatus == 0
      ) {
        this.$showCjToast({
          text: "只能生成今日的打卡日签",
          type: "warn",
        });
        return
      }
      if (this.workType == 2 && this.topData.dayCardStatus != 1) {
        this.$showCjToast({
          text: "先打卡才能生成日签",
          type: "warn",
        });
        return
      }
      if (!this.isCanvasOver) {
        this.$showCjToast({
          text: "日签生成中，请稍等",
          type: "warn",
        });
        // this.$refs.daysign.signDayInfoStart(this.signDayInfo)
      } else {
        this.showSignDay = true;
      }
    },
    //邀请好友
    clickInviteFriend() {
      if (this.bindPhoneSetting && this.bindPhoneSetting.shareBind) {
        if (utilJs.goBindMobile()) return;
      }
      this.$routerGo(this, "push", {
        path: "/homePage/spread/spreadCustom",
        query: {
          // clockInId: clockInId
          ckFrom: global.ckFrom.clockIn,
          cId: 0,
          extId: clockInId
        }
      });
    },
    //排行榜
    clickGoRank() {
      if (this.bindPhoneSetting && this.bindPhoneSetting.getBind) {
        if (utilJs.goBindMobile()) return;
      }
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/rankList",
        query: {
          clockId: clockInId,
          setScore: 1,
          type: this.homeWorkInfo.type
        }
      });
    },
    //学习记录
    clickGoStudyHistory(userId) {
      if (this.bindPhoneSetting && this.bindPhoneSetting.getBind) {
        if (utilJs.goBindMobile()) return;
      }
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/studyHistory",
        query: {
          clockId: clockInId,
          userId: userId || this.homeWorkInfo.userId,
          isMe: !userId,
          curSelectDate:this.curSelectDate,
          isTraining:this.isTraining
        }
      });
    },
    //关闭日签
    closeSignDay() {
      this.showSignDay = false;
    },
    //关闭证书
    closeCertificate() {
      this.showCertificate = false;
      if (this.homeWorkInfo.gitType == 2 && this.homeWorkInfo.hasGetCoupon == 0 && this.homeWorkInfo.isEnd == 1) {
        this.getReward();
      }
    },
    //日签绘制完成
    canvasOver() {
      this.isCanvasOver = true;
      console.log(this.isCanvasOver, '日签1')
      this.$loading.hide();
    },
    //闯关点击去打卡,如果是选择题 && 未达到分数 && 需要支付积分
    clickBerforClock() {
      if (this.bindPhoneSetting && this.bindPhoneSetting.getBind) {
        if (utilJs.goBindMobile()) return;
      }
      if (this.homeWorkInfo.isBeBlackList) {
        this.$showCjToast({
          text: "很抱歉，你已被拉为黑名单",
          type: "warn"
        });
        return;
      }
      if (this.enableCenter) {
        return
      }
      // 设置了分数达标 && 未达标
      if (
        this.homeWorkInfo.type == 2 &&
        this.homeWorkInfo.isSetTarget == 1 &&
        this.homeWorkInfo.isReachTarget == 0 &&
        this.homeWorkInfo.payPoint * 1 > 0
      ) {
        this.$cjConfirm({
          title: '继续闯关需支付',
          message: `${this.homeWorkInfo.payPoint * 1}${this.customPointName}`,
          confirmButtonText:'支付',
          onConfirm:() => {
            this.payPoint();
          }
        })
      } else {
        this.clickGoClockIn();
      }
    },
    //闯关打卡支付积分
    payPoint() {
      utilJs.postMethod(
        `${global.apiurl}signCard/payPoint/${this.curHwId}`,
        {},
        (res) => {
          this.clickGoClockIn();
        }
      );
    },
    //点击去打卡
    clickGoClockIn(item) {
      if (this.bindPhoneSetting && this.bindPhoneSetting.getBind) {
        if (utilJs.goBindMobile()) return;
      }
      if (this.homeWorkInfo.isBeBlackList) {
        this.$showCjToast({
          text: "很抱歉，你已被拉为黑名单",
          type: "warn"
        });
        return;
      }
      if (this.enableCenter) {
        return
      }
      if (this.workType == 2) {
        if (item.isShowTheme == 1 && item.readTime > 0) {
          this.goToDiary(item, '', 1)
          return
        } else {
          this.curHwId = item.hwId
          this.homeWorkInfo.status = item.status
          this.homeWorkInfo.type = item.type
          if (item.type == 2) {
            this.homeWorkInfo.continueNum = item.continueNum
          }
          if (item.type == 3) {
            this.homeWorkInfo.examMainId = item.examMainId
          }
        }
      }
      //选择题，并且未打过卡，则添加打卡记录后进入maxSignCount  每日最多可打卡次数 -1不限制
      if (this.homeWorkInfo.type == 2 && (this.homeWorkInfo.status == 0 || this.homeWorkInfo.status == 2 ||
      (this.homeWorkInfo.status == 1 && (this.maxSignCount == -1 || (this.maxSignCount > this.homeWorkInfo.hasSignCount))))) {
        this.addTest();
        return;
      }
      if (this.homeWorkInfo.type == 1) {
        //进入简答题
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/simpleQue",
          query: {
            curHwId: this.curHwId,
            clockId: clockInId,
            curDate: this.curSelectDate,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            isTraining:this.isTraining,
            workType:this.workType
          }
        });
      } else if (this.homeWorkInfo.type == 3) {
        //进入AI语音
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/voiceQue",
          query: {
            curHwId: this.curHwId,
            clockInId: clockInId,
            curDate: this.curSelectDate,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            workType:this.workType,
            examMainId:this.homeWorkInfo.status == 2 ? this.homeWorkInfo.examMainId : '-1'
          }
        });
      } else if (this.homeWorkInfo.type == 2) {
        console.log(this.homeWorkInfo.continueNum)
        //进入选择题
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/choiceQue",
          query: {
            curDate: this.curSelectDate,
            clockId: clockInId,
            curHwId: this.curHwId,
            curNum: this.homeWorkInfo.continueNum || 1,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            workType:this.workType
          }
        });
      } else {
        //进入关联表单
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/clockForm",
          query: {
            curDate: this.curSelectDate,
            clockId: clockInId,
            curHwId: this.curHwId,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            workType:this.workType
          }
        });
      }
    },
    //添加答题记录
    addTest() {
      let joinUrl = this.curSelectDate
        ? `${global.apiurl}signCard/dayJoinExam?hwId=${this.curHwId}&signColId=${clockInId}&day=${this.curSelectDate}&examMainId=-1`
        : `${global.apiurl}signCard/joinExam/${this.curHwId}?signColId=${clockInId}`;
      utilJs.getMethod(joinUrl, (res) => {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/choiceQue",
          query: {
            curHwId: this.curHwId,
            curNum: this.homeWorkInfo.continueNum || 1,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            curDate: this.curSelectDate,
            clockId: clockInId,
            workType:this.workType,
            examMainId: res.examMainId
          }
        });
      });
    },
    startselecthw(searchText) {
      this.searchhwName = searchText.searchValue;
      pageIndex = 1;
      this.getHomeWorkList();
    },
    clickselecthw(value) {
      this.selecthwItem = value;
      if (this.selecthwItem == '倒序') {
        this.sorthwType = 0
      } else if (this.selecthwItem == '正序') {
        this.sorthwType = 1
      }
      pageIndex = 1;
      this.getHomeWorkList()
    },
    //点击开始播放音频
    clickPlayAudio(audioUrl) {
      if (this.playAduioSrc == audioUrl) {
        this.playAduioSrc = "";
        document.getElementById("audio").src = this.playAduioSrc;
        return;
      }
      this.playAduioSrc = audioUrl;

      //返回mp3则用audio播放
      if (this.playAduioSrc) {
        document.getElementById("audio").src = this.playAduioSrc;
        //document.getElementById("audio").play();
        utilJs.audioPlayFun(document.getElementById("audio"), "play");
      }
    },
    //监听音频播放结束执行的内容
    playAudioEnd() {
      this.playAduioSrc = "";
      document.getElementById("audio").src = this.playAduioSrc;
    },

    //点赞
    clickZan(index, myAswerIndex) {
      if (isLoading) {
        return;
      }
      isLoading = true;
      //点赞自己
      let zanType = 0;
      let examMainId = "";
      if (index == -1) {
        zanType = this.homeWorkInfo.myResult[myAswerIndex].hasZan == 1 ? 2 : 1;
        examMainId = this.homeWorkInfo.myResult[myAswerIndex].examMainId;
      } else {
        zanType = this.studentWorkList[index].hasZan == 1 ? 2 : 1;
        examMainId = this.studentWorkList[index].examMainId;
      }

      utilJs.getMethod(
        `${global.apiurl}signCard/clickZan/${examMainId}?zanType=${zanType}`,
        (res) => {
          isLoading = false;
          if (res.status == 1) {
            this.$showCjToast({
              text: zanType == 1 ? "点赞成功" : "取消点赞",
              type: "success",
            });
            //点赞自己
            if (index == -1) {
              this.$set(
                this.homeWorkInfo.myResult[myAswerIndex],
                "hasZan",
                zanType == 2 ? 0 : 1
              );
              if (zanType == 1) {
                this.homeWorkInfo.myResult[myAswerIndex].zanMan.push({
                  nickname: res.nickname,
                  userId:res.userId
                });
              } else {
                let zanArr = this.homeWorkInfo.myResult[myAswerIndex].zanMan.filter((item) => {
                  return item.userId != res.userId;
                });
                this.$set(this.homeWorkInfo.myResult[myAswerIndex], "zanMan", zanArr);
              }
            } else {
              //点赞别人
              this.$set(
                this.studentWorkList[index],
                "hasZan",
                zanType == 2 ? 0 : 1
              );
              if (zanType == 1) {
                this.studentWorkList[index].zanMan.push({
                  nickname: res.nickname,
                  userId:res.userId
                });
              } else {
                let zanArr = this.studentWorkList[index].zanMan.filter((item) => {
                  return item.userId != res.userId;
                });
                this.$set(this.studentWorkList[index], "zanMan", zanArr);
              }
            }
          } else if (res.status == 2) {
            this.$showCjToast({
              text: res.message,
              type: "warn",
            });
          } else {
            this.$showCjToast({
              text: '操作失败',
              type: "warn",
            });
          }
        },
        (failRes) => {
          isLoading = false;
        }
      );
    },
    /**
     * 点击评论
     * index： -1 评论自己，其他:评论别人
     * cIndex： -1 评论别人的内容，其他：评论别人的评论
     */
    clickCom(index, cIndex, commentId, myAswerIndex, isTeacher) {
      console.log(index, cIndex, myAswerIndex, this.homeWorkInfo.isTeacher, 'clickCom')
      if (cIndex == -1 && (this.homeWorkInfo.isTeacher == 1 || this.homeWorkInfo.isTeacher == 2) && isTeacher) {
        curComIndex = index;
        myCurComIndex = myAswerIndex
        this.resultInfo = this.studentWorkList[index];
        console.log(index)
        this.resultIndex = index;
        this.showTeaCommentModal = true;
        this.playAduioSrc = "";
        document.getElementById("audio").src = this.playAduioSrc;
        this.enHwId = this.studentWorkList[index].hwId
        this.enDate = this.studentWorkList[index].startDay
        return;
      }
      this.commentId = commentId
      let examMainId = "";
      //点击自己的评论
      if (index == -1) {
        if (cIndex != -1) {
          console.log(this.homeWorkInfo.myResult[myAswerIndex])
          this.comType = this.homeWorkInfo.myResult[myAswerIndex].commentArr[cIndex].type;
        }
        examMainId = this.homeWorkInfo.myResult[myAswerIndex].examMainId;
        this.replyId =
          cIndex == -1
            ? ""
            : this.homeWorkInfo.myResult[myAswerIndex].commentArr[cIndex].userId;
        this.replyName =
          cIndex == -1
            ? ""
            : this.homeWorkInfo.myResult[myAswerIndex].commentArr[cIndex].nickname;
        this.enHwId = this.homeWorkInfo.myResult[myAswerIndex].hwId
        this.enDate = this.homeWorkInfo.myResult[myAswerIndex].startDay
      } else {
        //点击别人的评论
        if (cIndex != -1) {
          this.comType = this.studentWorkList[index].commentArr[cIndex].type;
        }
        examMainId = this.studentWorkList[index].examMainId;
        this.replyId =
          cIndex == -1
            ? ""
            : this.studentWorkList[index].commentArr[cIndex].userId;
        this.replyName =
          cIndex == -1
            ? ""
            : this.studentWorkList[index].commentArr[cIndex].nickname;
        this.enHwId = this.studentWorkList[index].hwId
        this.enDate = this.studentWorkList[index].startDay
      }
      curComIndex = index;
      myCurComIndex = myAswerIndex
      if (this.curComId != examMainId) {
        this.inputCom = "";
      }
      this.curComId = examMainId;
      this.showComInput = true;
      this.playAduioSrc = "";
      document.getElementById("audio").src = this.playAduioSrc;
    },

    //评论成功
    commentSuccess(comData, type) {
      let content = {
        type: comData.type,
        content: comData.content,
        nickname: comData.nickname,
        replyName: this.replyName,
        replyUserId: this.replyId,
        userId: this.homeWorkInfo.userId,
        imgArr: comData.imgArr,
        audioArr: comData.audioArr,
        videoArr: comData.videoArr || [],
        headimgurl:comData.headimgurl,
        commentId:comData.commentId,
        encodeUserId:localStorage.getItem("userId"),
        createdAt:comData.commentTime,
      };
      this.playAduioSrc = "";
      if (curComIndex == -1) {
        //评论自己
        this.homeWorkInfo.myResult[myCurComIndex].commentArr.push(content);
        if (comData.teacherCom) {
          this.$set(this.homeWorkInfo.myResult[myCurComIndex], "isHot", comData.isHot);
          this.$set(this.homeWorkInfo.myResult[myCurComIndex], "isTop", comData.isTop);
          this.$set(this.homeWorkInfo.myResult[myCurComIndex], "rank", comData.rank);
          this.$set(this.homeWorkInfo.myResult[myCurComIndex], "createdAt", comData.commentTime);
        }
      } else {
        //评论别人
        if (comData.teacherCom) {
          //老师点评
          this.$set(this.studentWorkList[curComIndex], "isHot", comData.isHot);
          this.$set(this.studentWorkList[curComIndex], "isTop", comData.isTop);
          this.$set(this.studentWorkList[curComIndex], "rank", comData.rank);
          this.$set(this.studentWorkList[curComIndex], "createdAt", comData.commentTime);
        }
        if (comData.teacherCom && this.sortType == 5) {
          //老师点评，当前类型是未点评，则把当前点评的这条数据移除掉
          this.studentWorkList.splice(curComIndex, 1);
        } else {
          this.studentWorkList[curComIndex].commentArr.push(content);
        }
      }
      this.commentId = content.commentId
      this.showTeaCommentModal = false;
      this.showComInput = false;
      this.replyName = "";
      this.inputCom = "";
      this.replyId = "";
      if (type == 1) {
        this.initData();
        this.topDetail();
        return
      }
    },

    //点击重测
    clickTestAgain(index) {
      if (this.studentWorkList[index].type == 1) {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/simpleQue",
          query: {
            curHwId: this.studentWorkList[index].hwId,
            examMainId: this.studentWorkList[index].examMainId,
            clockId: clockInId,
            curDate: this.studentWorkList[index].startDay,
            ttId: this.ttId,
            tpId: this.tpId,
            tlId: this.tlId,
            ckFrom: this.ckFrom,
            workType:this.workType
          }
        });
        return;
      } else if (this.studentWorkList[index].type == 4) {
        //进入AI语音
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/clockForm",
          query: {
            curDate: this.studentWorkList[index].startDay,
            clockId: clockInId,
            curHwId: this.studentWorkList[index].hwId,
            isReTest: 1,
            examMainId: this.studentWorkList[index].examMainId,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            workType:this.workType
          }
        });
        return;
      } else if (this.studentWorkList[index].type == 3) {
        //进入AI语音
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/voiceQue",
          query: {
            curHwId: this.studentWorkList[index].hwId,
            clockInId: clockInId,
            curDate: this.studentWorkList[index].startDay,
            isReTest: 1,
            examMainId: this.studentWorkList[index].examMainId,
            ttId: this.ttId, //营期ID
            tpId: this.tpId, //环节ID
            tlId: this.tlId, //课时ID
            ckFrom: this.ckFrom,
            workType:this.workType
          }
        });
        return;
      }
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/choiceQue",
        query: {
          curHwId: this.studentWorkList[index].hwId,
          curNum: 1,
          isReText: true,
          examMainId: this.studentWorkList[index].examMainId,
          curDate: this.studentWorkList[index].startDay,
          clockId: clockInId,
          workType:this.workType
        }
      });
    },

    //点击查看解析
    clickLookAswer(index) {
      if (this.studentWorkList[index].type == 1) {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/simpleQueResult",
          query: {
            curHwId: this.studentWorkList[index].hwId
          }
        });
      } else if (this.studentWorkList[index].type == 3) {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/voiceResult",
          query: {
            curHwId: this.studentWorkList[index].hwId,
            totalNum: this.studentWorkList[index].content,
            curDate: this.studentWorkList[index].startDay,
            examMainId: this.studentWorkList[index].examMainId,
            clockInId: clockInId,
            workType:this.workType
          }
        });
      } else {
        this.$routerGo(this, "push", {
          path: "/homePage/clockIn/homeWorkResult",
          query: {
            examMainId: this.studentWorkList[index].examMainId,
            isFromDetail: true,
            curDate: this.studentWorkList[index].startDay,
            workType:this.workType,
            clockInId: clockInId,
            curHwId : this.studentWorkList[index].hwId
          }
        });
      }
    },
    //显示获取积分
    showGetPoints() {
      let curHwIdNum = this.curSelectDate
        ? `${clockInId}-${this.curSelectDate}`
        : `${clockInId}-${this.curHwId}`;
      let localPointsArr = localStorage.getItem("showPointsArray");
      let pointsArr = (localPointsArr && JSON.parse(localPointsArr)) || [];
      if (
        !(localPointsArr && JSON.parse(localPointsArr).includes(curHwIdNum))
      ) {
        pointsArr.length < 99999
          ? pointsArr.push(curHwIdNum)
          : pointsArr.shift();
        localStorage.setItem("showPointsArray", JSON.stringify(pointsArr));
        this.integrateCount =
          this.homeWorkInfo.isEnd == 1
            ? (this.homeWorkInfo.homeworkPoint * 1 > 0 ? this.homeWorkInfo.completePoint * 1 + this.homeWorkInfo.homeworkPoint * 1 : this.homeWorkInfo.completePoint * 1)
            : this.homeWorkInfo.homeworkPoint * 1;
        this.showIntegrate = true;
      }
    },

    //获取作业本信息
    getHomeWorkDatail() {
      let postUrl = global.apiurl + `signCard/homeworkDetail/${this.curHwId}?isTraining=${this.isTraining}&hasRead=${hasRead}&refereeId=${this.refereeId}`
      if (this.themeId) {
        postUrl = postUrl + `&themeId=${this.themeId}`
      }
      utilJs.getMethod(postUrl,
        (res) => {
          this.homeWorkInfo = {}
          setDocumentTitle(res.courseName || "详情");
          if (res.startTime) {
            res.startTime = utilJs.changeTimeUtil(res.startTime);
          }
          if (res.endTime) {
            res.endTime = utilJs.changeTimeUtil(res.endTime);
          }
          if (res.subscribeStatus && res.subscribeStatus != 1) {
            this.noticesToast = true;
          }
          let myResultInfo = res.myResult
          this.homeWorkInfo = res;
          // if (this.homeWorkInfo.isTeacher == 1) {
          //   this.$routerGo(this, "replace", {
          //     path: `/homePage/clockIn/teaHomeWorker?fromDetail=1&clockInId=${clockInId}`
          //   });
          //   return
          // }
          if (this.first == 0) {
            this.appletInletInfo()
          }
          console.log('ccccccccccccccccccccccccc', this.homeWorkInfo)
          // this.homeWorkInfo.myResult = []
          if (res.myResult) {
            this.homeWorkInfo.myResult = []
            this.homeWorkInfo.myResult.push(myResultInfo)
          }
          let that = this
          clearInterval(readTimeContain)
          // 强制时间计算
          if (that.readTime > 0 && that.isShowTheme == 1) {
            readTimeContain = setInterval(function() {
              if (Number(that.readTime) != 0) {
                that.readTime = Number(that.readTime) - 1
              }
            }, 1000)
          }
          if (this.homeWorkInfo.status == 1) {
            this.setProgress()
          }
          this.subscribeStatus = res.subscribeStatus ? res.subscribeStatus : 0;
          if (this.isFirstJoin == 1 && res.hasPermission) {
            this.$cjConfirm({
              message: `您已开始进入闯关，请在${res.limitDay}天内完成闯关，过期将不能继续闯关`,
              showCancelButton: false,
              onConfirm:() => {
                 this.$routerGo(this, "push", {
                  path: `/homePage/clockIn/stuHomeWork?workType=3&fromDetail=1&clockInId=${clockInId}&curId=${this.curHwId}`
                });
                this.isFirstJoin = 0;
              }
            })
          }

          //可以获取证书，并且没有显示过，则自动弹出证书
          if (res.isShowCertificate == 1) {
            if (
              res.hadShowedCer == 0
            ) {
              this.getCertInfo(res.cerId);
            } else if (
            (res.homeworkPoint * 1 > 0 ||
              (res.completePoint * 1 > 0 && res.isEnd == 1)) && this.homeWorkInfo.myResult &&
            this.homeWorkInfo.myResult[0] &&
            res.isReachTarget == 1 && this.homeWorkInfo.myResult[0].isShowPoint && res.gitType == 1
          ) {
            this.showGetPoints();
          } else if (
              this.homeWorkInfo.gitType == 2 && this.homeWorkInfo.hasGetCoupon == 0 && res.isEnd == 1
            ) {
              this.getReward();
            }
          } else if (
            (res.homeworkPoint * 1 > 0 ||
              (res.completePoint * 1 > 0 && res.isEnd == 1)) && this.homeWorkInfo.myResult &&
            this.homeWorkInfo.myResult[0] &&
            res.isReachTarget == 1 && this.homeWorkInfo.myResult[0].isShowPoint && res.gitType == 1
          ) {
            this.showGetPoints();
          } else if (
            this.homeWorkInfo.gitType == 2 && this.homeWorkInfo.hasGetCoupon == 0 && res.isEnd == 1
          ) {
            this.getReward();
          }
          //判断签到信息是否为空
          if (
            Object.keys(this.signDayInfo).length == 0 &&
            this.topData.dayCardStatus == 1
          ) {
            this.$nextTick(() => {
              this.getlocationpoint();
            });
          }
          this.wechatShare();
            this.showStudentWorkList = true;
            pageIndex = 1;
            this.getStudentWorkList();
        }
      );
    },
    //获取日历打卡信息
    getCalendarHomeWork() {
      utilJs.getMethod(
        `${global.apiurl}signCard/themeDetail?signColId=${clockInId}&day=${this.curSelectDate}&hasRead=${hasRead}&refereeId=${this.refereeId}&time=` + new Date().getTime(),
        (res) => {
          this.homeWorkInfo = {}
          setDocumentTitle(res.resultInfo.courseName || "详情"); // eslint-disable-line
          this.curHwId = res.headInfo.hwId || 0;
          this.subscribeStatus = res.subscribeStatus || 0;
          if (res.subscribeStatus != 1) {
            this.noticesToast = true;
          }
          this.homeWorkInfo = {
            hwId: res.headInfo.hwId || 0,
            signColId: clockInId,
            name: res.headInfo.name || "",
            cover: res.headInfo.cover || "",
            description: res.headInfo.description || [],
            isAnalyze: res.headInfo.isAnalyze || 0,
            isExist: res.headInfo.isExist || 0,
            setScore: res.headInfo.setScore || 0,
            continueNum: res.resultInfo.continueNum || 0,
            type: res.headInfo.type || 1,
            courseName: res.resultInfo.courseName,
            courseCover: res.resultInfo.cover,
            gitType: res.resultInfo.gitType,
            status: res.resultInfo.status,
            hasMan: res.resultInfo.hasMan,
            isDisAgainSign: res.resultInfo.isDisAgainSign,
            dayCardStatus: res.resultInfo.dayCardStatus,
            isDisCheat: res.resultInfo.isDisCheat,
            isPrivate: res.resultInfo.isPrivate,
            isExpire: res.resultInfo.isExpire,
            isShowCard: res.resultInfo.isShowCard,
            myResult: res.resultInfo.myResult || [],
            userId: res.resultInfo.userId,
            startTime: res.resultInfo.startTime,
            endTime: res.resultInfo.endTime,
            nickname: res.resultInfo.nickname,
            supplyNum: res.resultInfo.supplyNum,
            isTeacher: res.resultInfo.isTeacher,
            endHour: res.resultInfo.endHour || "00:00",
            startHour: res.resultInfo.startHour || "23:59",
            homeworkPoint: res.resultInfo.homeworkPoint,
            completePoint: res.resultInfo.completePoint,
            isCertificate: res.resultInfo.isCertificate,
            isReachTarget: 1,
            isEnd: res.resultInfo.isEnd,
            isBeBlackList: res.isBeBlackList,
            enableRemind: res.enableRemind,
            buttonText: res.buttonText,
            isRestDay: res.isRestDay,
            hasGetCoupon:res.resultInfo.hasGetCoupon,
            hasSignCount:res.resultInfo.hasSignCount,
            examMainId:res.resultInfo.examMainId || -1,
            daySignShowData:res.resultInfo.daySignShowData,
          };
          // if (this.homeWorkInfo.isTeacher == 1) {
          //   this.$routerGo(this, "replace", {
          //     path: `/homePage/clockIn/teaHomeWorker?fromDetail=1&clockInId=${clockInId}`
          //   });
          //   return
          // }
          if (this.first == 0) {
            this.appletInletInfo()
          }
          this.showIconList = true
          clearInterval(readTimeContain)
          let that = this
          clearInterval(readTimeContain)
          if (that.readTime > 0 && that.isShowTheme == 1) {
            readTimeContain = setInterval(function() {
              if (Number(that.readTime) != 0) {
                that.readTime = Number(that.readTime) - 1
              }
            }, 1000)
          }
          this.mySignList = res.calendar;
          this.getDateInfo();
          if (this.homeWorkInfo.status == 1) {
            this.setProgress()
          }
          this.wechatShare();
          console.log( (res.resultInfo.homeworkPoint * 1 > 0 ||
              (res.resultInfo.completePoint * 1 > 0 &&
                res.resultInfo.isEnd == 1)) && this.homeWorkInfo.myResult[0] && this.homeWorkInfo.myResult[0].isShowPoint && this.homeWorkInfo.gitType == 1
          )
          //可以获取证书，并且没有显示过，则自动弹出证书
          if (res.resultInfo.isCertificate == 1) {
            if (
              res.resultInfo.hadShowedCer == 0
            ) {
              this.getCertInfo(res.resultInfo.cerId);
            } else if (
                (res.resultInfo.homeworkPoint * 1 > 0 ||
                  (res.resultInfo.completePoint * 1 > 0 &&
                    res.resultInfo.isEnd == 1)) && this.homeWorkInfo.myResult[0] && this.homeWorkInfo.myResult[0].isShowPoint && this.homeWorkInfo.gitType == 1
              ) {
              this.showGetPoints();
            } else if (
              this.homeWorkInfo.gitType == 2 && this.homeWorkInfo.hasGetCoupon == 0 && res.resultInfo.isEnd == 1
            ) {
              this.getReward();
            }
          } else if (
            (res.resultInfo.homeworkPoint * 1 > 0 ||
              (res.resultInfo.completePoint * 1 > 0 &&
                res.resultInfo.isEnd == 1)) && this.homeWorkInfo.myResult[0] && this.homeWorkInfo.myResult[0].isShowPoint && this.homeWorkInfo.gitType == 1
          ) {
            this.showGetPoints();
          } else if (
            this.homeWorkInfo.gitType == 2 && this.homeWorkInfo.hasGetCoupon == 0 && res.resultInfo.isEnd == 1
          ) {
            this.getReward();
          }
          console.log(Object.keys(this.signDayInfo).length == 0 &&
            res.resultInfo.dayCardStatus == 1, '日签3')
          //判断签到信息是否为空
          if (
            Object.keys(this.signDayInfo).length == 0 &&
            res.resultInfo.dayCardStatus == 1
          ) {
            this.$nextTick(() => {
              this.getlocationpoint();
            });
          }

          // if (
          //   (this.homeWorkInfo.isPrivate == 0 &&
          //     ((this.homeWorkInfo.status == 1 &&
          //       this.homeWorkInfo.isDisCheat == 1) ||
          //       this.homeWorkInfo.isDisCheat == 0)) ||
          //   this.homeWorkInfo.isTeacher == 1
          // ) {
            this.showStudentWorkList = true;
            pageIndex = 1;
            this.getStudentWorkList();
          // } else {
          //   this.showStudentWorkList = false;
          //   this.$nextTick(() => {
          //     window.scrollTo(0, this.curScollTop);
          //     if (this.curScollTop == (document.documentElement.scrollTop || document.body.scrollTop)) {
          //       this.curScollTopFlag = true
          //     }
          //   })
          // }
        }
      );
    },
    getHomeWorkListAll() {
      pageIndex = 1
      this.dataStatus = "HAS_MORE_DATA";
      this.getHomeWorkList()
    },
    pupilListAll() {
      pageIndex = 1
      this.dataStatus = "HAS_MORE_DATA";
      this.signCardPupilList()
    },
    tabtag(index) {
      this.tabIndex = index
      window.scrollTo(0, 0);
      pageIndex = 1
      this.dataStatus = "HAS_MORE_DATA";
      if (this.tabIndex == 0) {
        // this.getStudentWorkList();
        if (this.workType == 1) {
          this.getCalendarHomeWork();
        } else {
          this.getHomeWorkDatail();
        }
      } else if (this.tabIndex == 1) {
        this.getHomeWorkListAll()
      } else if (this.tabIndex == 2) {
        this.pupilListAll()
      }
      if (document.getElementById("audio")) {
        document.getElementById("audio").src = "";
      }
    },
    getunFinishedHwList() {
       utilJs.getMethod(
        global.apiurl +
          "signCard/unFinishedHwList" +
          "?signColId=" +
          clockInId,
        (res) => {
          this.unFinishedHwList = res
        },
        (failRes) => {
        }
      );
    },
    getHomeWorkList() {
      if (this.dataStatus == "LOADING") {
        return;
      }
      this.dataStatus = "LOADING";
      utilJs.getMethod(
        global.apiurl +
          "signCard/homeworkList/" +
          clockInId +
          "?page=" +
          pageIndex +
          "&limit=" +
          LIMIT +
          "&sortType=" +
          this.sorthwType +
          "&searchName=" +
          this.searchhwName,
        (res) => {
          for (let item of res.detailData.data) {
            item.startTime = utilJs.changeTimeUtil(item.startTime);
            item.endTime = utilJs.changeTimeUtil(item.endTime);
          }
          if (pageIndex == 1) {
            this.mainData = res.mainData;
            this.homeWorkList = res.detailData.data;
          } else {
            this.homeWorkList = [...this.homeWorkList, ...res.detailData.data];
          }
          if (res.detailData.to * 1 == res.detailData.total * 1) {
            this.dataStatus = res.detailData.total * 1 == 0 ? "NO_DATA" : "NO_MORE_DATA";
          } else {
            this.dataStatus = "HAS_MORE_DATA";
            pageIndex++;
          }
        },
        (failRes) => {
          this.dataStatus = "DATA_ERROR";
        }
      );
    },
    getLevelNum() {
      utilJs.getMethod(`${global.apiurl}signCard/blockadeList/${clockInId}?unPaginate=1&time=` + new Date().getTime(),
        res => {
          this.levelNum = res.dataList;
          this.hasBreak = res.hasBreak;
          this.finishPeopleNum = res.finishPeopleNum
          let hwIdIndex = 0
          for (let index in this.levelNum) {
            if (this.levelNum[index].hwId == this.curHwId) {
                hwIdIndex = index
            }
          }
          console.log(hwIdIndex)
          this.$nextTick(() => {
            if (this.$refs.levelIndex && this.$refs.levescroll) {
              this.$refs.levescroll.scrollLeft = this.$refs.levelIndex[5] && this.$refs.levelIndex[5].offsetLeft ? this.$refs.levelIndex[hwIdIndex].offsetLeft - this.$refs.levelIndex[5].offsetLeft : 0
              // console.log(this.$refs.levelIndex[5].offsetLeft, '获取第一个元素的scrollLeft1值');
            } else {
              setTimeout(() => {
                if (this.$refs.levelIndex && this.$refs.levescroll) {
                  this.$refs.levescroll.scrollLeft = this.$refs.levelIndex[5] && this.$refs.levelIndex[5].offsetLeft ? this.$refs.levelIndex[hwIdIndex].offsetLeft - this.$refs.levelIndex[5].offsetLeft : 0
                }
                // console.log(this.$refs.levelIndex, '获取第一个元素的scrollLeft2值');
              }, 2000);
            }
          });
        },
        failRes => {
        }
      );
    },
    chooseLockNum(item, index) {
      //点击下一个,如果是闯关打卡 && 没有权限 && 已打卡次数 >= 体验次数
      if (
        this.homeWorkInfo.nextId &&
        this.workType == 3 &&
        !this.homeWorkInfo.hasPermission &&
        this.homeWorkInfo.hasFinish >= this.homeWorkInfo.isExperienceLesson
      ) {
        if (this.homeWorkInfo.payType == 3) {
          this.showPassword = true;
        } else {
          this.$cjConfirm({
            title: '体验结束',
            message: '请购买课程后继续打卡',
            confirmButtonText:'去支付',
            onConfirm:() => {
              this.$routerGo(this, "push", {
                path: "/homePage/course/coursePay",
                query: {
                  extId: clockInId,
                  ckFrom: global.ckFrom.clockIn,
                  isFromInvite: 0,
                  cId: -1,
                  isFirstJoin: this.isFirstJoin
                }
              });
            }
          })
        }
      } else if (item.hwId && item.isUnlock == 1 || (item.isUnlock == 0 && item.reorder - 1 == this.hasBreak)) {
        this.curHwId = item.hwId
        this.getBaseConfig()
        // this.getHomeWorkDatail();
        let newUrl = `${
          window.location.href.split("#")[0]
          }#/homePage/clockIn/stuHomeWork?workType=${this.workType}&clockInId=${clockInId}&curDate=${
          this.curSelectDate}&curId=${this.curHwId}`;
        //解决进入排行榜，学习记录，邀请卡的时候回来导致页面是第一次进来的作业
        history.replaceState("stuHomeWork", "", newUrl);
      } else {
        this.$showCjToast({
          text: "请先打卡上一个课时",
          type: "warn",
        });
      }
    },
    goToDiary(clockInfo, index, head) {
      if (this.enableCenter && head == 1) {
        return
      }
      switch (this.workType) {
        case 1:
          let startTimeTamp = new Date(`${this.topData.startTime} ${this.topData.startHour}`.replace(/-/g, "/")).getTime();
          let endTimeTamp = new Date(`${this.topData.endTime} ${this.topData.endHour}`.replace(/-/g, "/")).getTime();
          let nowTimeTamp = new Date().getTime();
          let curTime = utilJs.dateFormat(nowTimeTamp);
          if (this.topData.isSingleTheme == 2) {
            curTime = clockInfo.startDay.split(' ')[0]
          } else {
            //日历打卡,若当前日期不在开始日期和结束日期之间，则从开始日期进入，否则从当前日期进入
            if (nowTimeTamp < startTimeTamp || nowTimeTamp > endTimeTamp) {
              curTime = this.topData.startTime;
            }
          }
          this.$routerGo(this, "push", {
            path: `/homePage/clockIn/stuHomeWorkDiary?workType=1&clockInId=${clockInId}&curDate=${curTime}`
          });
          break;
        case 2:
          //作业打卡，如果超过一个作业，则进入作业列表，否则进入作业详情
          this.$routerGo(this, "push", {
            path: "/homePage/clockIn/stuHomeWorkDiary",
            query: {
              workType: 2,
              curId: clockInfo.hwId,
              clockInId: clockInId,
              fromDetail: this.$route.query.fromDetail || "",
              ckFrom: this.ckFrom || ""
            }
          });
          break;
        case 3:
           //点击下一个,如果是闯关打卡 && 没有权限 && 已打卡次数 >= 体验次数//闯关打卡
          if (
            this.homeWorkInfo.nextId &&
            this.workType == 3 &&
            !this.homeWorkInfo.hasPermission &&
            this.homeWorkInfo.hasFinish >= this.homeWorkInfo.isExperienceLesson
          ) {
            if (this.homeWorkInfo.payType == 3) {
              this.showPassword = true;
            } else {
              this.$cjConfirm({
                title: '体验结束',
                message: '请购买课程后继续打卡',
                confirmButtonText:'去支付',
                onConfirm:() => {
                  this.$routerGo(this, "push", {
                    path: "/homePage/course/coursePay",
                    query: {
                      extId: clockInId,
                      ckFrom: global.ckFrom.clockIn,
                      isFromInvite: 0,
                      cId: -1,
                      isFirstJoin: this.isFirstJoin
                    }
                  });
                }
              })
            }
          } else if (clockInfo.isUnlock == 1 || (clockInfo.isUnlock == 0 && clockInfo.reorder - 1 == this.hasBreak)) {
            this.$routerGo(this, "push", {
              path: `/homePage/clockIn/stuHomeWorkDiary?workType=3&clockInId=${clockInId}&curId=${clockInfo.hwId}`
            });
            break;
          } else {
            this.$showCjToast({
              text: "请先打卡上一个课时",
              type: "warn",
            });
          }
      }
    },
    //成员列表
    signCardPupilList() {
      if (this.dataStatus == "LOADING") {
        return;
      }
      this.dataStatus = "LOADING";
      utilJs.getMethod(
        `${global.apiurl}signCard/pupilList/${clockInId}?limit=${LIMIT}&page=${pageIndex}`,
        (res) => {
          if (pageIndex == 1) {
            this.pupilList = res.data
          } else {
            this.pupilList = [...this.pupilList, ...res.data];
          }
          if (res.data && (res.data.length < LIMIT)) {
            this.dataStatus = pageIndex == 1 && res.data.length == 0 ? "NO_DATA" : "NO_MORE_DATA";
          } else {
            this.dataStatus = "HAS_MORE_DATA";
            pageIndex++;
          }
        },
        (failRes) => {
          this.dataStatus = "DATA_ERROR";
        }
      );
    },
    //获取学生作业列表信息
    getStudentWorkList() {
      if (this.dataStatus == "LOADING") {
        return;
      }
      this.dataStatus = "LOADING";
      utilJs.getMethod(
        `${global.apiurl}signCard/studentSubmitListAll?signColId=${clockInId}&hwId=${this.hwId}&classId=${this.classId}&endTime=${this.endTime}&day=${this.day}&startTime=${this.startTime}&sortType=${this.sortType}&searchName=${this.searchName}&searchType=${this.searchType}&page=${pageIndex}&limit=${LIMIT}&time=` + new Date().getTime(),
        (res) => {
          if (pageIndex == 1) {
            this.studentWorkList = res.data;
          } else {
            this.studentWorkList = [...this.studentWorkList, ...res.data];
          }
          console.log(res.data && (res.data.length < LIMIT))
          if (res.data && (res.data.length < LIMIT)) {
            this.dataStatus = pageIndex == 1 && res.data.length == 0 ? "NO_DATA" : "NO_MORE_DATA";
          } else {
            this.dataStatus = "HAS_MORE_DATA";
            pageIndex++;
          }
          this.$nextTick(() => {
            window.scrollTo(0, this.curScollTop);
            let clientHeight = document.body.clientHeight && document.documentElement.clientHeight ? Math.min(document.body.clientHeight, document.documentElement.clientHeight) : Math.max(document.body.clientHeight, document.documentElement.clientHeight);
            if (!this.curScollTopFlag && this.curScollTop + clientHeight <= (document.body.scrollHeight)) {
              this.curScollTopFlag = true
            }
          })
        },
        (failRes) => {
          this.dataStatus = "DATA_ERROR";
        }
      );
    },

    // 根据当前选中日期，绘制本周日历
    getDateInfo() {
      let dateArr = [];
      //获取今天的时间 2018-11-23
      let nowDateStr = utilJs.dateFormat(+new Date());
      let curDate = new Date(this.curSelectDate.replace(/-/g, "/"));
      //当前选中的日期时间戳
      let curDateTamp = new Date(
        this.curSelectDate.replace(/-/g, "/")
      ).getTime();
      let nowWeek = curDate.getDay();
      let startTimeTamp = new Date(
        this.homeWorkInfo.startTime.replace(/-/g, "/")
      ).getTime();
      let endTimeTamp = new Date(
        this.homeWorkInfo.endTime.replace(/-/g, "/")
      ).getTime();
      let weekMap = {
        0: "日",
        1: "一",
        2: "二",
        3: "三",
        4: "四",
        5: "五",
        6: "六"
      };
      // let weekMap = {
      //   0: "周一",
      //   1: "周二",
      //   2: "周三",
      //   3: "周四",
      //   4: "周五",
      //   5: "周六",
      //   6: "周天"
      // };
      for (let i = 0; i < 7; i++) {
        let subDayTamp = (i - nowWeek) * ONE_DAY_TIMES_TAMP;
        //本周第i天的时间戳
        let itemTamp = curDateTamp + subDayTamp;
        let itemDate = new Date(itemTamp);
        let itemDay = itemDate.getDate();
        let itemMonth = itemDate.getMonth() + 1;
        let itemYear = itemDate.getFullYear();
        itemMonth = itemMonth < 10 ? `0${itemMonth}` : itemMonth;
        itemDay = itemDay < 10 ? `0${itemDay}` : itemDay;
        //第i天日期
        let strDate = `${itemYear}-${itemMonth}-${itemDay}`;
        let itemType = 1;
        if (strDate == nowDateStr) {
          //当天
          itemDay = "今";
        }
        if (itemTamp < startTimeTamp || itemTamp > endTimeTamp) {
          itemType = 0;
        }

        for (let key of this.mySignList) {
          //判断是否签到了
          if (key.day == strDate) {
            itemType = key.type;
          }
        }
        let dateItem = {
          type: itemType,
          week: weekMap[i],
          day: itemDay,
          date: strDate
        };
        dateArr.push(dateItem);
      }
      this.myCalendarList = dateArr;
    },
    //关闭积分弹窗，显示证书
    closeShareInt() {
      this.showIntegrate = false;
      if (
        this.certificateInfo &&
        JSON.stringify(this.certificateInfo) != "{}"
      ) {
        this.showCertificate = true;
        this.$refs.certificate.showcertInfo()
        // this.showCertificate = true;
      }
    },

    //获取证书信息
    getCertInfo(cerId) {
      utilJs.getMethod(
        // /api/Certificate/cardShow?
        `${global.apiurl}Certificate/cardShow?prodType=${global.ckFrom.clockIn}&prodId=${clockInId}&type=1&day=${this.curSelectDate}`,
        (res) => {
          let titleArr = [];
          let titleName = res.name ? res.name : res.prodName;
          let firstTitle = titleName.substring(0, 13);
          let sencendTitle = titleName.substring(13, 26);
          firstTitle && titleArr.push(firstTitle);
          sencendTitle && titleArr.push(sencendTitle);
          let cardCover = res.image.includes("?")
            ? `${res.image}&${+new Date()}`
            : `${res.image}?${+new Date()}`;
          let headimgurl = res.headimgurl.includes("?")
            ? `${res.headimgurl}&${+new Date()}`
            : `${res.headimgurl}?${+new Date()}`;
            let homeQrcode = res.signBaseInfo.homeQrcode.includes("?")
            ? `${res.signBaseInfo.homeQrcode}&${+new Date()}`
            : `${res.signBaseInfo.homeQrcode}?${+new Date()}`;
          let qrCodeUrl = res.signBaseInfo.qrCodeUrl.includes("?")
            ? `${res.signBaseInfo.qrCodeUrl}&${+new Date()}`
            : `${res.signBaseInfo.qrCodeUrl}?${+new Date()}`;
          let continuoueDay = null;
          let defineShowContent = res.defineShowContent
          if (res.signBaseInfo.type == 3 && defineShowContent.includes(8)) {
            //解锁课时
            continuoueDay = res.signBaseInfo.hasSignDay;
          } else if (res.signBaseInfo.type != 3 && defineShowContent.includes(9)) {
            continuoueDay = res.signBaseInfo.continueDay;
          }
          let signDay = null;
          if (res.signBaseInfo.type == 3 && defineShowContent.includes(12)) {
            //通关天数
            signDay = res.signBaseInfo.spendDays;
          } else if (res.signBaseInfo.type != 3 && defineShowContent.includes(8)) {
            signDay = res.signBaseInfo.hasSignDay;
          }
          let qrcodeUrlSelf = "";
          let qrCodeText = "长按识别二维码加入打卡"
          if (res.redirectTo == 1) {
            qrcodeUrlSelf = qrCodeUrl
          } else if (res.redirectTo == 2) {
            qrcodeUrlSelf = homeQrcode;
          } else if (res.redirectTo == 3) {
            qrcodeUrlSelf = res.customizeQrCode.img;
          }
          qrCodeText = res.qrCodeText ? res.qrCodeText : qrCodeText
          console.log(qrCodeText)
          let info = {
            isDefaultWord: res.contentType,
            word: res.content || [],
            title:res.title,
            signDay: signDay,
            continuoueDay: continuoueDay,
            good: defineShowContent.includes(10) ? res.signBaseInfo.hotNum : null,
            like: defineShowContent.includes(11) ? res.signBaseInfo.zanNum : null,
            titleArr: titleArr,
            nickname: res.nickname,
            realName: res.realName,
            cardCover: cardCover,
            headimgurl:
              headimgurl || require("../../../assets/defult_head.png"),
            qrcodeImg: qrcodeUrlSelf,
            // 通关天数||打卡天数
            iconSign:
              res.signBaseInfo.type == 2
                ? 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_num.png'
                : res.signBaseInfo.type == 3
                  ? 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_level_day.png'
                  : 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_day.png',
            iconContinue:
              res.signBaseInfo.type == 3
                ? 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_level_course.png'
                : 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_continue.png',
            iconGood: 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_good.png',
            iconLike: 'https://ck-bkt-knowledge-payment.oss-cn-hangzhou.aliyuncs.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/icon_like.png',
            customizeControl:res.customizeControl,
            certificateType:res.certificateType,
            customizeImage:res.customizeImage,
            avatarShowType:res.nameTypeShow,
            shareDesc:res.shareDesc,
            enableAvatarShow:res.enableAvatarShow,
            qrCodeText:qrCodeText,
            createdAt:res.createdAt,
            enableShowQrCode:res.enableShowQrCode,
            enableInstitution:res.enableInstitution, //是否展示发证机构：1=展示；0=隐藏
            institutionName:res.institutionName, //机构名称
            enableGrantTime:res.enableGrantTime, //是否展示发证时间  1=展示；0=隐藏
            enableNumber:res.enableNumber, //是否展示证书编号 1=展示；0=隐藏
            number:res.number, //起始编号
            enableStamp:res.enableStamp, //是否展示章戳  1=展示；2=自定义; 0=隐藏
            stampImg:res.stampImg, //章戳自定义图片
            shapeType:res.shapeType,
            id:res.cardLogId
          };
          this.certificateInfo = info;
          console.log(this.certificateInfo)
          //(完成本次打卡积分>0 && 未全部打完卡) || (完成全部打卡积分>0 && 完成全部打卡) && 已打完卡 && 达到目标分数
          if (
            (this.homeWorkInfo.homeworkPoint * 1 > 0 ||
              (this.homeWorkInfo.completePoint * 1 > 0 &&
                this.homeWorkInfo.isEnd == 1)) &&
            this.homeWorkInfo.myResult[0] && this.homeWorkInfo.myResult[0].isShowPoint && this.homeWorkInfo.gitType == 1 &&
            this.homeWorkInfo.isReachTarget == 1
          ) {
            this.showGetPoints();
          } else {
            this.showCertificate = true;
          }
          this.updateShowCerStatus(res.cardLogId)
        }
      );
    },

    //获取日签信息
    getSignDayInfo(lat, lon) {
      utilJs.getMethod(
        `${global.apiurl}signCard/showDayCard/${clockInId}?lat=${lat}&lon=${lon}`,
        (res) => {
          let dateArr = res.day.split("-");
          let monthTime = dateArr[1];
          let dayTime = dateArr[2];
          let cardCover = "";
          if (res.enableImgLoop) {
            cardCover = res.cardCoverArr;
          } else {
            cardCover = res.cardCover;
          }
          let info = {
            fontColor: res.fontColor,
            type: res.type,
            name: res.name,
            nickname: res.nickname,
            word: res.word || [],
            isDefaultWord: res.isDefaultWord,
            cardCover:
              cardCover ||
              "https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/clockIn/daysign_img.png",
            monthTime:monthTime,
            dayTime:dayTime,
            dateStr: monthTime + "月" + dayTime + "日",
            city: res.city || "未知",
            headimgurl:
              res.headimgurl || require("../../../assets/defult_head.png"),
            userId: res.userId,
            hasWork: res.hasWork,
            qrcodeUrl: res.qrcodeUrl,
            allDay: res.allDay || 0,
            hasSignDay: res.hasSignDay || 0,
            isBackMoney: res.payType == 4 ? 1 : 0,
            overPercent: res.overstep,
            daySignType: res.daySignType || [],
            dcStyleType: res.dcStyleType || 4,
            enableDcWord: res.enableDcWord,
            daySignContent: res.daySignContent,
            daySignShowData: res.daySignShowData,
            timeType: res.timeType,
          };
          this.signDayInfo = info;
          console.log(this.signDayInfo, 'this.signDayInfo')
          this.$refs.daysign.signDayInfoStart(this.signDayInfo)
          clearInterval(this._getLocationtime)
        }
      );
    },

    //获取地理位置
    getlocationpoint() {
      clearInterval(this._getLocationtime)
      if (this.homeWorkInfo.daySignShowData.isShowArea == 0 || (utilJs.isAndroidApp() || utilJs.isIOSAppALL())) {
        console.log(this.homeWorkInfo.daySignShowData.isShowArea == 0 || (utilJs.isAndroidApp() || utilJs.isIOSAppALL()), '日签7')
        this.getSignDayInfo("", "");
        return;
      }
      if (!utilJs.isWeiXin()) {
        console.log('日签6')
        this._getLocationtime = setTimeout(() => {
          this.getSignDayInfo("", "");
        }, 2000);
        return
      }
      wxUtilJs.getLocation().then(
        (res) => {
          console.log('日签4')
          this.getSignDayInfo(res.latitude, res.longitude);
        },
        (failRes) => {
          console.log('日签5')
          this.getSignDayInfo("", "");
        }
      );
    },

    initData() {
      this.showAialogPop = false
      isLoading = false;
      pageIndex = 1;
      curComIndex = "";
      myCurComIndex = '';
      this.replyId = "";
      this.curComId = "";
      this.dataStatus = "HAS_MORE_DATA";
      this.showCertificate = false;
      this.showComInput = false;
      this.searchName = "";
      this.searchhwName = "";
      this.showTeaCommentModal = false;
      this.showSignDay = false;
      this.showVideo = false;
      this.inputCom = "";
      this.playAduioSrc = "";
      this.replyName = "";
      this.sortType = 0; //排序
      this.sortTypeLocal = 1;
      this.homeWorkInfo = null;
      this.studentWorkList = []; //提交的作业列表
      this.certificateInfo = {};
      this.showPassword = false;
      this.showIntegrate = false;
      this.showAiAnswer = false;
      this.integrateCount = 0;
      this.noticesToast = false;
      this.showClassListName = '所有成员';
      this.showClassListid = '';
      this.operationMenu = {}
      this.operationMenuLength = 0
      this.getBaseConfig()
    },
    showOprationSheet(index) {
      this.myResultIndex = index
      this.myOperationShow = true
    },
    calcOperation(item, index) {
      let temObj = []
      if (item.isDisAgainSign) {
        temObj.push({name:'重测', value:0})
      }
      if (item.isAnalyze && item.type == 1) {
        temObj.push({name:'查看解析', value:1})
      }
      if (item.enableDelete) {
        temObj.push({name:'删除', value:2})
      }
      this.operationMenu = temObj
      this.operationMenuLength = Object.keys(this.operationMenu).length
      this.showOprationSheet(index)
    },
    // 方法名：删除考试记录
    // 方法：signCard/deleteExamLog
    // 方式：post
    // 参数：examMainId
    clickeDelete(index) {
      let that = this
      this.$cjConfirm({
        title: '提示',
        message: '删除后无法恢复，确定删除日记?',
        onConfirm:() => {
          utilJs.postMethod(
            global.apiurl + "signCard/deleteExamLog",
            { examMainId: this.studentWorkList[index].examMainId },
            res => {
              window.scrollTo(0, 0);
              pageIndex = 1
              this.dataStatus = "HAS_MORE_DATA";
              if (this.workType == 1) {
                this.getCalendarHomeWork();
              } else {
                this.getHomeWorkDatail();
              }
              if (that.workType == 3) {
                that.getLevelNum()
              }
              if (document.getElementById("audio")) {
                document.getElementById("audio").src = "";
              }
            },
          );
        }
      })
    },
    clickOperationMenu(item, key) {
      if (item.value == 0) {
        this.clickTestAgain(this.myResultIndex)
      }
      if (item.value == 1) {
        this.clickLookAswer(this.myResultIndex)
      }
      if (item.value == 2) {
        this.clickeDelete(this.myResultIndex)
      }
    },
    goStuAnswerResult(info) {
      // let query = {
      //     clockInId: clockInId,
      //     curHwId : this.homeWorkInfo.hwId,
      //     stuHwId:info.hwId,
      //     curSelectDate:this.curSelectDate,
      //     examMainId: info.examMainId,
      //     totalNum:info.type == 3 ? info.aiNum : 0
      //   }
      // console.log(query)
      // return
      this.$routerGo(this, "push", {
        path: "/homePage/clockIn/stuShortAnswerResult",
        query: {
          clockInId: clockInId,
          curHwId : this.homeWorkInfo.hwId,
          stuHwId:info.hwId,
          curSelectDate:this.curSelectDate,
          examMainId: info.examMainId,
          totalNum:info.type == 3 ? info.aiNum : 0
        }
      });
    },
    //分享
    wechatShare() {
      let sData = localStorage.getItem("homeWorkShareInfo") ? JSON.parse(localStorage.getItem("homeWorkShareInfo")) : {};
      let shareLogo = localStorage.getItem("shareLogo");
      // let shareTitle = localStorage.getItem("shareTitle");
      let title = this.topData.name
      let shareImg =
        this.homeWorkInfo.cover ||
        this.homeWorkInfo.courseCover ||
        sData.shareImg || shareLogo;
      let shareUrl = this.curSelectDate
        ? `${window.location.href.split("#")[0]}#${
        this.$route.path
        }?workType=1&clockInId=${clockInId}&curDate=${
        this.curSelectDate
        }&refereeId=${localStorage.getItem("userId")}`
        : `${window.location.href.split("#")[0]}#${
        this.$route.path
        }?workType=${this.workType}&clockInId=${clockInId}&curId=${
        this.curHwId
        }&refereeId=${localStorage.getItem("userId")}`;
      let shareDesc = "点击查看详情";
      let shareData = {
        title: title,
        shareImg: shareImg,
        shareUrl: shareUrl,
        shareDesc: shareDesc
      };
      localStorage.setItem("homeWorkShare", JSON.stringify(shareData));
      utilJs.wechatConfig(
        shareUrl,
        title,
        shareImg,
        shareDesc,
        function () { },
        true
      );
    },
    //手机端分享
    appShare() {
      let sData = localStorage.getItem("homeWorkShareInfo") ? JSON.parse(localStorage.getItem("homeWorkShareInfo")) : {};
      let shareLogo = localStorage.getItem("shareLogo");
      // let shareTitle = localStorage.getItem("shareTitle");
      let title = this.topData.name;
      let shareImg =
        this.homeWorkInfo.cover ||
        this.homeWorkInfo.courseCover ||
        sData.shareImg || shareLogo;
      let shareUrl = this.curSelectDate
        ? `${window.location.href.split("#")[0]}#${
        this.$route.path
        }?workType=1&clockInId=${clockInId}&curDate=${
        this.curSelectDate
        }&refereeId=${localStorage.getItem("userId")}`
        : `${window.location.href.split("#")[0]}#${
        this.$route.path
        }?workType=2&clockInId=${clockInId}&curId=${
        this.curHwId
        }&refereeId=${localStorage.getItem("userId")}`;
      let shareDesc = "点击查看详情";
      let shareData = {
        title: title,
        shareImg: shareImg,
        shareUrl: shareUrl,
        shareDesc: shareDesc
      };
      utilJs.appShareTrue(
        shareData.title,
        shareData.shareImg,
        shareData.shareUrl,
        shareData.shareDesc
      );
    },
    windowScrollFunction() {
      if (this.curScollTopFlag && this.tabIndex == 0) {
        let scrollTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
        this.curScollTop = scrollTop;
      }
      utilJs.handleLoading(() => {
        if (this.dataStatus == 'HAS_MORE_DATA') {
          if (this.tabIndex == 0) {
            this.getStudentWorkList();
          } else if (this.tabIndex == 1) {
            // if (this.workType == 1 || this.workType == 2) {
              this.getHomeWorkList()
            // } else {
            //   this.getLevelList()
            // }
          } else if (this.tabIndex == 2) {
            this.signCardPupilList();
          }
        }
      });
    },
    async initgetClassList() {
      await this.getClassList()
    },
    handleLaunch(e) {
        console.log('handleLaunch---', e)
        // this.$emit('handleLaunch')
    },
    handleErrorFn(e) {
      this.$showCjToast({
        text: e.errMsg || '无法打开小程序，请升级微信版本',
        type: "warn",
      })
    },
    clickGoWxApp() {
      let fullPath = `${this.path}?${this.wxappQuery}`;
      let query = `?appId=${this.appid}&path=${encodeURIComponent(JSON.stringify(fullPath))}`;
      utilJs.miniProgramGoTo('push', '/pages/home/goWxApp/index' + query);
    },
    closeAialogPop() {
      this.showAialogPop = false
    },
    appletInletInfo() {
      utilJs.getMethod(
        `${global.apiurl}signCard/appletInletInfo?signColId=` + this.clockInId,
        (res) => {
          if (!utilJs.isWeiXin()) {
            return
          }
          // enablePop是否弹窗提醒：1=是；0=否
          if (res.enablePop == 1 && res.enableAppletRemind == 1 && !this.$isStore()) {
            this.showAialogPop = true
          }
          this.first = 1
          // enableBanner是否横幅提醒：1=是；0=否
          this.enableBanner = !this.$isStore() ? res.enableBanner : 0
          // enableCenter是否个人中心进入打卡小程序：1=是；0=否
          this.enableCenter = !this.$isStore() ? res.enableCenter : 0
        }
      );
    },
  },
  activated() {
    if (document.getElementById("audio")) {
      document.getElementById("audio").src = "";
    }
    this.$loading.hide();
    // this.showAll = false
    this.tabIndex = 0
    this.isShowClockSearch = false
    this.curHwId = this.$route.query.curId || "";
    this.selectItem = (this.selectList.length > 0 && [this.selectList[0][0]]) || []
    this.selecthwItem = (this.selecthw.length > 0 && [this.selecthw[0][0]]) || []
    this.sorthwType = 1
    clockInId = this.$route.query.clockInId || "";
    this.clockInId = this.$route.query.clockInId || "";
    hasRead = this.$route.query.hasRead || "";
    this.ttId = this.$route.query.ttId || "";
    this.tpId = this.$route.query.tpId || "";
    this.tlId = this.$route.query.tlId || "";
    this.themeId = this.$route.query.themeId || '';
    this.ckFrom = this.$route.query.ckFrom || "";
    this.fromDetail = this.$route.query.fromDetail || "";
    this.workType = this.$route.query.workType;
    this.refereeId = this.$route.query.refereeId || ""
    this.curSelectDate = this.$route.query.curDate || "";
    this.getCurYearMonth(this.curSelectDate)
    this.isTraining = this.$route.query.isTraining || ""; //仅训练营进入闯关中间关卡可以获取详情
    this.isFirstJoin = this.$route.query.isFirstJoin || 0; //第一次进入时弹出提示框
    if (this.$store.state.oem_store.clockCalendar) {
      this.curSelectDate = this.$store.state.oem_store.clockCalendar.date;
      this.getCurYearMonth(this.curSelectDate)
      let newUrl = `${
        window.location.href.split("#")[0]
        }#/homePage/clockIn/stuHomeWork?workType=1&clockInId=${clockInId}&curDate=${
        this.curSelectDate
        }`;
      //解决进入排行榜，学习记录，邀请卡的时候回来导致页面是第一次进来的作业
      history.replaceState("stuHomeWork", "", newUrl);
    }
    this.signDayInfo = {};
    this.isCanvasOver = false;
    this.showCouponDialog = false;
    this.showReward = false;
    this.getAlready = false;
    this.showAccountQcode = false;
    this.adCoupon = [];
    this.initData();
    this.topDetail();

    getBindPhoneSetting(global.ckFrom.clockIn).then(res => {
      this.bindPhoneSetting = res;
    });
    this.initgetClassList();
    if (this.workType == 2) {
      this.getunFinishedHwList()
    }
    //获取阿里云签名，除了微信浏览器以外
    if (!utilJs.isWeiXin()) {
      utilJs.getAliSign(`${global.apiurl}imageSign`, (res) => {
        this.imgData = res;
      });
    }

    window.addEventListener("scroll", this.windowScrollFunction);

    //解决ios播放没声音
    this.$nextTick(function () {
      try {
        if (typeof WeixinJSBridge == "undefined") {
          if (document.addEventListener) {
            document.addEventListener(
              "WeixinJSBridgeReady",
              function () {
                document.getElementById("audio").play();
              },
              false
            );
          } else if (document.attachEvent) {
            document.attachEvent("WeixinJSBridgeReady", function () {
              document.getElementById("audio").play();
            });
            document.attachEvent("onWeixinJSBridgeReady", function () {
              document.getElementById("audio").play();
            });
          }
          WeixinJSBridge.invoke("getNetworkType", {}, function (e) {
            // eslint-disable-line
            // 在这里拿到 e.err_msg, 这里面就包含了所有的网络类型
            document.getElementById("audio").play();
            console.log(
              "WeixinJSBridgeWeixinJSBridgeWeixinJSBridgeWeixinJSBridge"
            );
          });
        }
      } catch (error) {
        // continue regardless of error
      }
    });
  },
  beforeDestroy() { },
  deactivated() {
    this.dataStatus = "NO_MORE_DATA";
    window.removeEventListener("scroll", this.windowScrollFunction);
    this.$store.commit("updateClockCalendar", null);
    if (document.getElementById("audio")) {
      document.getElementById("audio").src = "";
    }
    this.$loading.hide();
    this.showSignDay = false;
    this.curScollTopFlag = false
    this.isShowClockSearch = true
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style lang="scss" scoped>
.sort-box {
  top: 1.7rem;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
}

.icon-sign {
  position: absolute;
  overflow: hidden;
  top: 0.05rem;
  left: 0.05rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.3rem;
  background-color: transparent;
}
.sign-color {
  position: absolute;
  width: 0;
  height: 0;
  left: -0.45rem;
  top: -0.15rem;
  width: 0;
  height: 0;
  border-bottom: 0.5rem solid #FFB102;
  border-left: 0.55rem solid transparent;
  border-right: 0.55rem solid transparent;
  transform: rotate(-45deg);
}
.sign-active {
  border-bottom: .5rem solid #fff ;
}

/* .sign-transp {
  position: absolute;
  right: 0;
  bottom: 0;
  border-bottom: 50px solid #565656;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
} */
.box-analyze {
  height: 0.8rem;
  /* background: rgba(255, 120, 0, 0.1); */
  border-radius: 0.4rem 0 0 0.4rem;
}
.top_triangle {
  height: 0px;
  width: 0px;
  border-width: 0.25rem;
  border-style: solid;
  border-color: transparent transparent #ffffff transparent;
  right: 0.8rem;
  top: -0.4rem;
}
.changeRole {
  position: fixed;
  bottom: 2rem;
  right: 0;
  /* background: #FE7900; */
  /* box-shadow: 0 2px 4px 0 rgba(254,121,0,0.30); */
  border-radius: 2.5rem 0 0 2.5rem;
}
.mb4_default .theme-bd-r2 {
  border-right: 2px solid #ff300c;
}
.popColor /deep/ .vux-cell-value{
  color: #333333;
}
.c-minh140{
  min-height: 3.5rem;
}
.c-classAlert{
  box-shadow: 0 0.05rem 0.25rem 0 rgba(0,0,0,0.10);
}
.c-mimw160{
  min-width: 4rem;;
}
.data-active {
  color: #fff;
}
.data-active .c-fc-gray {
  color: #fff!important;
}
/deep/ .weui-actionsheet {
  border-radius: 10px 10px 0 0 ;
}
/deep/ .weui-actionsheet__menu{
  border-radius: 10px 10px 0 0 ;
}
/deep/ .weui-actionsheet__cell {
  font-size: .75rem;
  padding: 15px 0;
  margin: 0 13px;
}
/deep/ .weui-actionsheet__action {
  margin-top: 0;
  background-color: #F6F7F9;
}
.teaHeadbg {
  background: url("../../../assets/i/wap/clockIn/teaHeadBg.png");
  background-size: cover;
}
.c-ml-4{
  margin-left: -0.4rem ;
}
.c-p-b-6{
  bottom: -0.15rem;
}
.c-pv14 {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}
.c-lh52 {
  line-height: 1.3rem;
}
.noStart{
  background:rgba(204,204,204,1);
}
.doit{
  color: #3DCF56;
  background:rgba(61,207,86,0.1);
}
.nodoit{
  color: #ffffff;
  background:rgba(204,204,204,1);
}
.noExpire{
  color: #999999;
  background:rgba(153,153,153,0.1);
}
.c-p-isExpire{
  top: -0.4rem;
  right: -0.4rem;
}
.c-p-typeQueMap{
  top: 0rem;
  left: 0rem;
  border-bottom-right-radius: 0.35rem;;
}
.selectPicker >>> .weui-cell__ft {
  padding: 0 !important;
}
.selectPicker >>> .weui-cell {
  padding: 0 !important;
}
.selectPicker >>> .weui-cell__ft:after {
  display: none !important;
}
.selectPicker  /deep/  .vux-cell-value {
  color: #666 !important;;
}
.nounlock{
  background: rgba(204,204,204,0.30);
}
.c-p-b-03{
  bottom: -0.3rem;
}
.c-bgTittle{
  background-image: linear-gradient(270deg, #FEF2EB 0%, #FCE9F6 100%);
}
.open-tag-wrap {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: transparent;
}
.launch-btn {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}
.onlyIcon{
  left: -0.26rem;
  top: -0.96rem;
}
.onlyBtn{
  background-image: linear-gradient(90deg, #5C95FF 14%, #76CAFF 91%);
}
.mod-renewal {
  background: #faddc0;
  min-height: 3rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.75rem 0.75rem 0 0;
  overflow: hidden;
  background: url("../../../assets/i/wap/clockIn/renewal_tip_bg.png") no-repeat
    top center;
  background-size:100% ;
  .renewal-btn {
    width: 3.6rem;
    height: 1.4rem;
    border-radius: 0.8rem;
    background: #976800;
  }
}
.renew-notice {
  position: absolute;
  right: 0.5rem;
  top: -0.1rem;
  line-height: 1;
  padding: 0 0.4rem;
}
</style>
